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

Commit

Permalink
deterministic choice of variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
xcaruso committed Apr 15, 2020
1 parent b78d3ef commit f17860f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/sage/rings/polynomial/skew_polynomial_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.polynomial.skew_polynomial_element import SkewPolynomialBaseringInjection

WORKING_CENTER_MAX_TRIES = 1000


# Helper functions

Expand Down Expand Up @@ -1322,21 +1324,22 @@ def __init__(self, base_ring, twist_map, name, sparse, category=None):
sage: S.center() is Z
True
"""
import random, string
SkewPolynomialRing.__init__(self, base_ring, twist_map, name, sparse, category)
self._order = twist_map.order()
(self._constants, self._embed_constants) = twist_map.fixed_field()

# Configure and create center
self._center = { }
self._center_variable_name = 'z'
while self._center_variable_name is not None:
for i in range(WORKING_CENTER_MAX_TRIES):
try:
self._working_center = self.center()
self._center_variable_name = None
break
except ValueError:
self._center_variable_name = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
pass
self._center_variable_name = "z%s_" % i
if self._center_variable_name is not None:
raise NotImplementedError("unable to create the center")


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

0 comments on commit f17860f

Please sign in to comment.