Skip to content

Commit e31cc79

Browse files
author
Release Manager
committed
gh-37069: Use Parent in number fields and QQ Towards the removal of `ParentWithGens` : use parent in number fields and in QQ ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #37069 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents d79e87b + 936661d commit e31cc79

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/sage/rings/number_field/number_field.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@
7777
# ****************************************************************************
7878
from __future__ import annotations
7979
from sage.misc.cachefunc import cached_method
80-
from sage.misc.superseded import (deprecation,
81-
deprecated_function_alias)
80+
from sage.misc.superseded import deprecation
8281

8382

8483
import sage.libs.ntl.all as ntl
@@ -109,6 +108,7 @@
109108
from .class_group import SClassGroup
110109

111110
from sage.structure.element import is_Element
111+
from sage.structure.parent import Parent
112112
from sage.structure.sequence import Sequence
113113
from sage.structure.factorization import Factorization
114114
from sage.structure.category_object import normalize_names
@@ -209,7 +209,6 @@ def proof_flag(t):
209209
import sage.groups.abelian_gps.abelian_group
210210
import sage.rings.complex_interval_field
211211

212-
from sage.structure.parent_gens import ParentWithGens
213212
from sage.structure.factory import UniqueFactory
214213
from . import number_field_element
215214
from . import number_field_element_quadratic
@@ -1379,7 +1378,7 @@ def __init__(self, polynomial, name, latex_name,
13791378
else:
13801379
assert category.is_subcategory(default_category), "%s is not a subcategory of %s" % (category, default_category)
13811380

1382-
ParentWithGens.__init__(self, QQ, name, category=category)
1381+
Parent.__init__(self, base=QQ, names=name, category=category)
13831382
if not isinstance(polynomial, polynomial_element.Polynomial):
13841383
raise TypeError("polynomial (=%s) must be a polynomial" % repr(polynomial))
13851384

src/sage/rings/rational_field.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
import sage.rings.number_field.number_field_base as number_field_base
6363
from sage.misc.fast_methods import Singleton
6464
from sage.misc.superseded import deprecated_function_alias
65-
from sage.structure.parent_gens import ParentWithGens
65+
from sage.structure.parent import Parent
6666
from sage.structure.sequence import Sequence
6767

6868

@@ -235,8 +235,9 @@ def __init__(self):
235235
"""
236236
from sage.categories.basic import QuotientFields
237237
from sage.categories.number_fields import NumberFields
238-
ParentWithGens.__init__(self, self, category=[QuotientFields().Metric(),
239-
NumberFields()])
238+
Parent.__init__(self, base=self,
239+
category=[QuotientFields().Metric(),
240+
NumberFields()])
240241
self._assign_names(('x',), normalize=False) # ?????
241242
self._populate_coercion_lists_(init_no_parent=True)
242243

@@ -862,7 +863,7 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True):
862863
if p != infty:
863864
if check and not is_prime(p):
864865
raise ValueError("all entries in list must be prime"
865-
" or -1 for infinite place")
866+
" or -1 for infinite place")
866867
R = Qp(p)
867868
if R(b).is_square():
868869
raise ValueError("second argument must be a nonsquare with"
@@ -1055,7 +1056,7 @@ def power_basis(self):
10551056
sage: QQ.power_basis()
10561057
[1]
10571058
"""
1058-
return [ self.gen() ]
1059+
return [self.gen()]
10591060

10601061
def extension(self, poly, names, **kwds):
10611062
r"""
@@ -1133,7 +1134,7 @@ def _an_element_(self):
11331134
sage: QQ.an_element() # indirect doctest
11341135
1/2
11351136
"""
1136-
return Rational((1,2))
1137+
return Rational((1, 2))
11371138

11381139
def some_elements(self):
11391140
r"""
@@ -1247,7 +1248,7 @@ def random_element(self, num_bound=None, den_bound=None, *args, **kwds):
12471248
den = ZZ.random_element(1, den_bound+1, *args, **kwds)
12481249
while den == 0:
12491250
den = ZZ.random_element(1, den_bound+1, *args, **kwds)
1250-
return self((num,den))
1251+
return self((num, den))
12511252

12521253
def zeta(self, n=2):
12531254
"""
@@ -1381,7 +1382,7 @@ def selmer_group_iterator(self, S, m, proof=True):
13811382

13821383
from sage.misc.misc_c import prod
13831384
for ev in product(*[range(o) for o in ords]):
1384-
yield prod((p**e for p,e in zip(KSgens, ev)), one)
1385+
yield prod((p**e for p, e in zip(KSgens, ev)), one)
13851386

13861387
def selmer_space(self, S, p, proof=None):
13871388
r"""
@@ -1520,7 +1521,7 @@ def quadratic_defect(self, a, p, check=True):
15201521
return v + 1
15211522

15221523
#################################
1523-
## Coercions to interfaces
1524+
# Coercions to interfaces
15241525
#################################
15251526
def _gap_init_(self):
15261527
r"""
@@ -1658,12 +1659,12 @@ def _factor_univariate_polynomial(self, f):
16581659
(10) * (x^5 - 1/10)
16591660
sage: QQ._factor_univariate_polynomial(10*x^5 - 10)
16601661
(10) * (x - 1) * (x^4 + x^3 + x^2 + x + 1)
1661-
16621662
"""
1663-
G = list(f._pari_with_name().factor())
1663+
G = f._pari_with_name().factor()
16641664

16651665
# normalize the leading coefficients
1666-
F = [(f.parent()(g).monic(), int(e)) for (g,e) in zip(*G)]
1666+
P = f.parent()
1667+
F = [(P(g).monic(), int(e)) for g, e in zip(*G)]
16671668

16681669
from sage.structure.factorization import Factorization
16691670
return Factorization(F, f.leading_coefficient())

0 commit comments

Comments
 (0)