Skip to content

Commit c76e573

Browse files
author
Release Manager
committed
gh-40881: sage.categories.finite_fields: don't import from integer_ring Importing `ZZ` from the integer ring creates an import cycle, ``` integer_ring -> integer -> rational -> rational_field -> categories/finite_fields -> integer_ring ``` I noticed this because the cycle has started causing an `ImportError` when I attempt to import `ZZ`. This commit doesn't fix the problem (there are other cycles), but it is minimally invasive and does improve the import graph a tiny bit. Edit: a better fix for this would be to break the dependence of integers on rationals, but that would be a much larger change. URL: #40881 Reported by: Michael Orlitzky Reviewer(s): Dima Pasechnik
2 parents 73534d0 + 626d5ce commit c76e573

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/sage/categories/finite_fields.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from sage.categories.category_with_axiom import CategoryWithAxiom
1717
from sage.categories.enumerated_sets import EnumeratedSets
1818
from sage.rings.integer import Integer
19-
from sage.rings.integer_ring import ZZ
2019
from sage.misc.cachefunc import cached_method
2120

2221

@@ -332,7 +331,7 @@ def _tonelli(self):
332331
if not self.is_square():
333332
raise ValueError("element is not a square")
334333
g = self.parent().quadratic_nonresidue()
335-
even_exp, odd_order = (q - ZZ.one()).val_unit(2)
334+
even_exp, odd_order = (q - Integer(1)).val_unit(2)
336335
e = 0
337336
for i in range(2, even_exp+1):
338337
tmp = self * (pow(g, -e))

0 commit comments

Comments
 (0)