Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit f17860f

Browse files
committed
deterministic choice of variable names
1 parent b78d3ef commit f17860f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/sage/rings/polynomial/skew_polynomial_ring.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
6060
from sage.rings.polynomial.skew_polynomial_element import SkewPolynomialBaseringInjection
6161

62+
WORKING_CENTER_MAX_TRIES = 1000
63+
6264

6365
# Helper functions
6466

@@ -1322,21 +1324,22 @@ def __init__(self, base_ring, twist_map, name, sparse, category=None):
13221324
sage: S.center() is Z
13231325
True
13241326
"""
1325-
import random, string
13261327
SkewPolynomialRing.__init__(self, base_ring, twist_map, name, sparse, category)
13271328
self._order = twist_map.order()
13281329
(self._constants, self._embed_constants) = twist_map.fixed_field()
13291330

13301331
# Configure and create center
13311332
self._center = { }
13321333
self._center_variable_name = 'z'
1333-
while self._center_variable_name is not None:
1334+
for i in range(WORKING_CENTER_MAX_TRIES):
13341335
try:
13351336
self._working_center = self.center()
13361337
self._center_variable_name = None
1338+
break
13371339
except ValueError:
1338-
self._center_variable_name = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
1339-
pass
1340+
self._center_variable_name = "z%s_" % i
1341+
if self._center_variable_name is not None:
1342+
raise NotImplementedError("unable to create the center")
13401343

13411344

13421345
def center(self, name=None, names=None, default=False):

0 commit comments

Comments
 (0)