Skip to content

Commit 7df421d

Browse files
committed
get rid of CommutativeRing in p-adics
1 parent d617df4 commit 7df421d

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

src/sage/rings/padics/local_generic.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
from sage.rings.integer import Integer
2828
from sage.rings.integer_ring import ZZ
2929
from sage.rings.infinity import Infinity
30-
from sage.rings.ring import CommutativeRing
30+
from sage.structure.parent import Parent
3131

3232

33-
class LocalGeneric(CommutativeRing):
33+
class LocalGeneric(Parent):
3434
def __init__(self, base, prec, names, element_class, category=None):
3535
r"""
3636
Initialize ``self``.
@@ -74,10 +74,10 @@ def __init__(self, base, prec, names, element_class, category=None):
7474
category = category.Metric().Complete().Infinite()
7575
if default_category is not None:
7676
category = check_default_category(default_category, category)
77-
CommutativeRing.__init__(self, base, names=(names,),
78-
normalize=False, category=category)
77+
Parent.__init__(self, base=base, names=(names,),
78+
normalize=False, category=category)
7979

80-
def is_capped_relative(self):
80+
def is_capped_relative(self) -> bool:
8181
r"""
8282
Return whether this `p`-adic ring bounds precision in a capped
8383
relative fashion.
@@ -102,7 +102,7 @@ def is_capped_relative(self):
102102
"""
103103
return False
104104

105-
def is_capped_absolute(self):
105+
def is_capped_absolute(self) -> bool:
106106
r"""
107107
Return whether this `p`-adic ring bounds precision in a
108108
capped absolute fashion.
@@ -127,7 +127,7 @@ def is_capped_absolute(self):
127127
"""
128128
return False
129129

130-
def is_fixed_mod(self):
130+
def is_fixed_mod(self) -> bool:
131131
r"""
132132
Return whether this `p`-adic ring bounds precision in a fixed
133133
modulus fashion.
@@ -154,7 +154,7 @@ def is_fixed_mod(self):
154154
"""
155155
return False
156156

157-
def is_floating_point(self):
157+
def is_floating_point(self) -> bool:
158158
r"""
159159
Return whether this `p`-adic ring bounds precision in a floating
160160
point fashion.
@@ -179,7 +179,7 @@ def is_floating_point(self):
179179
"""
180180
return False
181181

182-
def is_lattice_prec(self):
182+
def is_lattice_prec(self) -> bool:
183183
r"""
184184
Return whether this `p`-adic ring bounds precision using
185185
a lattice model.
@@ -208,7 +208,7 @@ def is_lattice_prec(self):
208208
"""
209209
return False
210210

211-
def is_relaxed(self):
211+
def is_relaxed(self) -> bool:
212212
r"""
213213
Return whether this `p`-adic ring bounds precision in a relaxed
214214
fashion.
@@ -224,7 +224,7 @@ def is_relaxed(self):
224224
"""
225225
return False
226226

227-
def _latex_(self):
227+
def _latex_(self) -> str:
228228
r"""
229229
Latex.
230230

src/sage/rings/padics/witt_vector_ring.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
# (at your option) any later version.
2222
# https://www.gnu.org/licenses/
2323
# ****************************************************************************
24-
25-
2624
from itertools import product
25+
from typing import Iterator
2726

2827
from sage.categories.commutative_rings import CommutativeRings
2928
from sage.categories.fields import Fields
@@ -42,15 +41,14 @@
4241
from sage.rings.polynomial.polynomial_element import Polynomial
4342
from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
4443
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
45-
from sage.rings.ring import CommutativeRing
44+
from sage.structure.parent import Parent
4645
from sage.sets.primes import Primes
4746
from sage.structure.unique_representation import UniqueRepresentation
4847

4948

5049
def fast_char_p_power(x, n, p=None):
5150
r"""
52-
Return `x^n` assuming that `x` lives in a ring of
53-
characteristic `p`.
51+
Return `x^n` assuming that `x` lives in a ring of characteristic `p`.
5452
5553
If `x` is not an element of a ring of characteristic `p`,
5654
this throws an error.
@@ -120,7 +118,7 @@ def fast_char_p_power(x, n, p=None):
120118
return xn
121119

122120

123-
class WittVectorRing(CommutativeRing, UniqueRepresentation):
121+
class WittVectorRing(Parent, UniqueRepresentation):
124122
r"""
125123
Return the appropriate `p`-typical truncated Witt vector ring.
126124
@@ -263,14 +261,13 @@ def __classcall_private__(cls, coefficient_ring, prec=1, p=None, algorithm=None)
263261

264262
return child.__classcall__(child, coefficient_ring, prec, p)
265263

266-
def __init__(self, coefficient_ring, prec, prime):
264+
def __init__(self, coefficient_ring, prec, prime) -> None:
267265
r"""
268-
Initialises ``self``.
266+
Initialise ``self``.
269267
270268
EXAMPLES::
271269
272-
sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4)
273-
sage: W
270+
sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4); W
274271
Ring of truncated 5-typical Witt vectors of length 4 over Univariate Polynomial Ring in t over Finite Field of size 5
275272
sage: type(W)
276273
<class 'sage.rings.padics.witt_vector_ring.WittVectorRing_phantom_with_category'>
@@ -281,9 +278,10 @@ def __init__(self, coefficient_ring, prec, prime):
281278
self._prec = prec
282279
self._prime = prime
283280

284-
CommutativeRing.__init__(self, self)
281+
Parent.__init__(self, base=coefficient_ring,
282+
category=CommutativeRings())
285283

286-
def __iter__(self):
284+
def __iter__(self) -> Iterator:
287285
"""
288286
Iterator for truncated Witt vector rings.
289287
@@ -347,7 +345,7 @@ def _coerce_map_from_(self, S):
347345
if (isinstance(S, WittVectorRing)
348346
and S.precision() >= self._prec and S.prime() == self._prime
349347
and self._coefficient_ring.has_coerce_map_from(
350-
S.coefficient_ring())):
348+
S.coefficient_ring())):
351349
return (any(isinstance(S, rng) for rng in self._always_coerce)
352350
or (S.precision() != self._prec
353351
or S.coefficient_ring() is not self._coefficient_ring)
@@ -358,7 +356,7 @@ def _coerce_map_from_(self, S):
358356

359357
def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
360358
"""
361-
Generates the sum and product polynomials defining the ring laws of
359+
Generate the sum and product polynomials defining the ring laws of
362360
truncated Witt vectors for the ``standard`` algorithm.
363361
364362
EXAMPLES::
@@ -421,7 +419,7 @@ def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
421419
self._sum_polynomials[n] = S(self._sum_polynomials[n])
422420
self._prod_polynomials[n] = S(self._prod_polynomials[n])
423421

424-
def _latex_(self):
422+
def _latex_(self) -> str:
425423
r"""
426424
Return a `\LaTeX` representation of ``self``.
427425
@@ -439,7 +437,7 @@ def _latex_(self):
439437
return "W_{%s}\\left(%s\\right)" % (latex(self._prec),
440438
latex(self._coefficient_ring))
441439

442-
def _repr_(self):
440+
def _repr_(self) -> str:
443441
"""
444442
Return a string representation of the ring.
445443
@@ -498,7 +496,7 @@ def coefficient_ring(self):
498496
"""
499497
return self._coefficient_ring
500498

501-
def is_finite(self):
499+
def is_finite(self) -> bool:
502500
"""
503501
Return whether ``self`` is a finite ring.
504502
@@ -572,7 +570,9 @@ def prod_polynomials(self, variables=None):
572570

573571
def random_element(self, *args, **kwds):
574572
"""
575-
Return a random truncated Witt vector. Extra arguments are passed to
573+
Return a random truncated Witt vector.
574+
575+
Extra arguments are passed to
576576
the random generator of the coefficient ring.
577577
578578
EXAMPLES::
@@ -621,8 +621,9 @@ def sum_polynomials(self, variables=None):
621621

622622
def teichmuller_lift(self, x):
623623
"""
624-
Return the Teichmüller lift of ``x`` in ``self``. This lift is
625-
sometimes known as the multiplicative lift of ``x``.
624+
Return the Teichmüller lift of ``x`` in ``self``.
625+
626+
This lift is sometimes known as the multiplicative lift of ``x``.
626627
627628
EXAMPLES::
628629
@@ -656,9 +657,9 @@ class WittVectorRing_finotti(WittVectorRing):
656657
"""
657658
Element = WittVector_finotti
658659

659-
def __init__(self, coefficient_ring, prec, prime):
660+
def __init__(self, coefficient_ring, prec, prime) -> None:
660661
r"""
661-
Initialises ``self``.
662+
Initialise ``self``.
662663
663664
EXAMPLES::
664665
@@ -798,9 +799,9 @@ class WittVectorRing_phantom(WittVectorRing):
798799
"""
799800
Element = WittVector_phantom
800801

801-
def __init__(self, coefficient_ring, prec, prime):
802+
def __init__(self, coefficient_ring, prec, prime) -> None:
802803
r"""
803-
Initialises ``self``.
804+
Initialise ``self``.
804805
805806
EXAMPLES::
806807
@@ -859,9 +860,9 @@ class WittVectorRing_pinvertible(WittVectorRing):
859860
"""
860861
Element = WittVector_pinvertible
861862

862-
def __init__(self, coefficient_ring, prec, prime):
863+
def __init__(self, coefficient_ring, prec, prime) -> None:
863864
r"""
864-
Initialises ``self``.
865+
Initialise ``self``.
865866
866867
EXAMPLES::
867868
@@ -901,9 +902,9 @@ class WittVectorRing_standard(WittVectorRing):
901902
"""
902903
Element = WittVector_standard
903904

904-
def __init__(self, coefficient_ring, prec, prime):
905+
def __init__(self, coefficient_ring, prec, prime) -> None:
905906
r"""
906-
Initialises ``self``.
907+
Initialise ``self``.
907908
908909
EXAMPLES::
909910

0 commit comments

Comments
 (0)