Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Parent in number fields and QQ #37069

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
# ****************************************************************************
from __future__ import annotations
from sage.misc.cachefunc import cached_method
from sage.misc.superseded import (deprecation,
deprecated_function_alias)
from sage.misc.superseded import deprecation


import sage.libs.ntl.all as ntl
Expand Down Expand Up @@ -109,6 +108,7 @@
from .class_group import SClassGroup

from sage.structure.element import is_Element
from sage.structure.parent import Parent
from sage.structure.sequence import Sequence
from sage.structure.factorization import Factorization
from sage.structure.category_object import normalize_names
Expand Down Expand Up @@ -210,7 +210,6 @@ def proof_flag(t):
import sage.groups.abelian_gps.abelian_group
import sage.rings.complex_interval_field

from sage.structure.parent_gens import ParentWithGens
from sage.structure.factory import UniqueFactory
from . import number_field_element
from . import number_field_element_quadratic
Expand Down Expand Up @@ -1380,7 +1379,7 @@ def __init__(self, polynomial, name, latex_name,
else:
assert category.is_subcategory(default_category), "%s is not a subcategory of %s" % (category, default_category)

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

Expand Down Expand Up @@ -12762,7 +12761,6 @@ def _splitting_classes_gens_(K, m, d):
"""
from sage.groups.abelian_gps.abelian_group import AbelianGroup

R = K.ring_of_integers()
Zm = IntegerModRing(m)
unit_gens = Zm.unit_gens()
Zmstar = AbelianGroup(len(unit_gens), [x.multiplicative_order() for x in unit_gens])
Expand Down
21 changes: 11 additions & 10 deletions src/sage/rings/rational_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import sage.rings.number_field.number_field_base as number_field_base
from sage.misc.fast_methods import Singleton
from sage.misc.superseded import deprecated_function_alias
from sage.structure.parent_gens import ParentWithGens
from sage.structure.parent import Parent
from sage.structure.sequence import Sequence


Expand Down Expand Up @@ -235,8 +235,9 @@ def __init__(self):
"""
from sage.categories.basic import QuotientFields
from sage.categories.number_fields import NumberFields
ParentWithGens.__init__(self, self, category=[QuotientFields().Metric(),
NumberFields()])
Parent.__init__(self, base=self,
category=[QuotientFields().Metric(),
NumberFields()])
self._assign_names(('x',), normalize=False) # ?????
self._populate_coercion_lists_(init_no_parent=True)

Expand Down Expand Up @@ -862,7 +863,7 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True):
if p != infty:
if check and not is_prime(p):
raise ValueError("all entries in list must be prime"
" or -1 for infinite place")
" or -1 for infinite place")
R = Qp(p)
if R(b).is_square():
raise ValueError("second argument must be a nonsquare with"
Expand Down Expand Up @@ -1055,7 +1056,7 @@ def power_basis(self):
sage: QQ.power_basis()
[1]
"""
return [ self.gen() ]
return [self.gen()]

def extension(self, poly, names, **kwds):
r"""
Expand Down Expand Up @@ -1133,7 +1134,7 @@ def _an_element_(self):
sage: QQ.an_element() # indirect doctest
1/2
"""
return Rational((1,2))
return Rational((1, 2))

def some_elements(self):
r"""
Expand Down Expand Up @@ -1247,7 +1248,7 @@ def random_element(self, num_bound=None, den_bound=None, *args, **kwds):
den = ZZ.random_element(1, den_bound+1, *args, **kwds)
while den == 0:
den = ZZ.random_element(1, den_bound+1, *args, **kwds)
return self((num,den))
return self((num, den))

def zeta(self, n=2):
"""
Expand Down Expand Up @@ -1381,7 +1382,7 @@ def selmer_group_iterator(self, S, m, proof=True):

from sage.misc.misc_c import prod
for ev in product(*[range(o) for o in ords]):
yield prod((p**e for p,e in zip(KSgens, ev)), one)
yield prod((p**e for p, e in zip(KSgens, ev)), one)

def selmer_space(self, S, p, proof=None):
r"""
Expand Down Expand Up @@ -1520,7 +1521,7 @@ def quadratic_defect(self, a, p, check=True):
return v + 1

#################################
## Coercions to interfaces
# Coercions to interfaces
#################################
def _gap_init_(self):
r"""
Expand Down Expand Up @@ -1663,7 +1664,7 @@ def _factor_univariate_polynomial(self, f):
G = list(f._pari_with_name().factor())

# normalize the leading coefficients
F = [(f.parent()(g).monic(), int(e)) for (g,e) in zip(*G)]
F = [(f.parent()(g).monic(), int(e)) for (g, e) in zip(*G)]
fchapoton marked this conversation as resolved.
Show resolved Hide resolved

from sage.structure.factorization import Factorization
return Factorization(F, f.leading_coefficient())
Expand Down
Loading