21
21
# (at your option) any later version.
22
22
# https://www.gnu.org/licenses/
23
23
# ****************************************************************************
24
-
25
-
26
24
from itertools import product
25
+ from typing import Iterator
27
26
28
27
from sage .categories .commutative_rings import CommutativeRings
29
28
from sage .categories .fields import Fields
42
41
from sage .rings .polynomial .polynomial_element import Polynomial
43
42
from sage .rings .polynomial .polynomial_ring import PolynomialRing_generic
44
43
from sage .rings .polynomial .polynomial_ring_constructor import PolynomialRing
45
- from sage .rings . ring import CommutativeRing
44
+ from sage .structure . parent import Parent
46
45
from sage .sets .primes import Primes
47
46
from sage .structure .unique_representation import UniqueRepresentation
48
47
49
48
50
49
def fast_char_p_power (x , n , p = None ):
51
50
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`.
54
52
55
53
If `x` is not an element of a ring of characteristic `p`,
56
54
this throws an error.
@@ -120,7 +118,7 @@ def fast_char_p_power(x, n, p=None):
120
118
return xn
121
119
122
120
123
- class WittVectorRing (CommutativeRing , UniqueRepresentation ):
121
+ class WittVectorRing (Parent , UniqueRepresentation ):
124
122
r"""
125
123
Return the appropriate `p`-typical truncated Witt vector ring.
126
124
@@ -263,14 +261,13 @@ def __classcall_private__(cls, coefficient_ring, prec=1, p=None, algorithm=None)
263
261
264
262
return child .__classcall__ (child , coefficient_ring , prec , p )
265
263
266
- def __init__ (self , coefficient_ring , prec , prime ):
264
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
267
265
r"""
268
- Initialises ``self``.
266
+ Initialise ``self``.
269
267
270
268
EXAMPLES::
271
269
272
- sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4)
273
- sage: W
270
+ sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4); W
274
271
Ring of truncated 5-typical Witt vectors of length 4 over Univariate Polynomial Ring in t over Finite Field of size 5
275
272
sage: type(W)
276
273
<class 'sage.rings.padics.witt_vector_ring.WittVectorRing_phantom_with_category'>
@@ -281,9 +278,10 @@ def __init__(self, coefficient_ring, prec, prime):
281
278
self ._prec = prec
282
279
self ._prime = prime
283
280
284
- CommutativeRing .__init__ (self , self )
281
+ Parent .__init__ (self , base = coefficient_ring ,
282
+ category = CommutativeRings ())
285
283
286
- def __iter__ (self ):
284
+ def __iter__ (self ) -> Iterator :
287
285
"""
288
286
Iterator for truncated Witt vector rings.
289
287
@@ -347,7 +345,7 @@ def _coerce_map_from_(self, S):
347
345
if (isinstance (S , WittVectorRing )
348
346
and S .precision () >= self ._prec and S .prime () == self ._prime
349
347
and self ._coefficient_ring .has_coerce_map_from (
350
- S .coefficient_ring ())):
348
+ S .coefficient_ring ())):
351
349
return (any (isinstance (S , rng ) for rng in self ._always_coerce )
352
350
or (S .precision () != self ._prec
353
351
or S .coefficient_ring () is not self ._coefficient_ring )
@@ -358,7 +356,7 @@ def _coerce_map_from_(self, S):
358
356
359
357
def _generate_sum_and_product_polynomials (self , coefficient_ring , prec , p ):
360
358
"""
361
- Generates the sum and product polynomials defining the ring laws of
359
+ Generate the sum and product polynomials defining the ring laws of
362
360
truncated Witt vectors for the ``standard`` algorithm.
363
361
364
362
EXAMPLES::
@@ -421,7 +419,7 @@ def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
421
419
self ._sum_polynomials [n ] = S (self ._sum_polynomials [n ])
422
420
self ._prod_polynomials [n ] = S (self ._prod_polynomials [n ])
423
421
424
- def _latex_ (self ):
422
+ def _latex_ (self ) -> str :
425
423
r"""
426
424
Return a `\LaTeX` representation of ``self``.
427
425
@@ -439,7 +437,7 @@ def _latex_(self):
439
437
return "W_{%s}\\ left(%s\\ right)" % (latex (self ._prec ),
440
438
latex (self ._coefficient_ring ))
441
439
442
- def _repr_ (self ):
440
+ def _repr_ (self ) -> str :
443
441
"""
444
442
Return a string representation of the ring.
445
443
@@ -498,7 +496,7 @@ def coefficient_ring(self):
498
496
"""
499
497
return self ._coefficient_ring
500
498
501
- def is_finite (self ):
499
+ def is_finite (self ) -> bool :
502
500
"""
503
501
Return whether ``self`` is a finite ring.
504
502
@@ -572,7 +570,9 @@ def prod_polynomials(self, variables=None):
572
570
573
571
def random_element (self , * args , ** kwds ):
574
572
"""
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
576
576
the random generator of the coefficient ring.
577
577
578
578
EXAMPLES::
@@ -621,8 +621,9 @@ def sum_polynomials(self, variables=None):
621
621
622
622
def teichmuller_lift (self , x ):
623
623
"""
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``.
626
627
627
628
EXAMPLES::
628
629
@@ -656,9 +657,9 @@ class WittVectorRing_finotti(WittVectorRing):
656
657
"""
657
658
Element = WittVector_finotti
658
659
659
- def __init__ (self , coefficient_ring , prec , prime ):
660
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
660
661
r"""
661
- Initialises ``self``.
662
+ Initialise ``self``.
662
663
663
664
EXAMPLES::
664
665
@@ -798,9 +799,9 @@ class WittVectorRing_phantom(WittVectorRing):
798
799
"""
799
800
Element = WittVector_phantom
800
801
801
- def __init__ (self , coefficient_ring , prec , prime ):
802
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
802
803
r"""
803
- Initialises ``self``.
804
+ Initialise ``self``.
804
805
805
806
EXAMPLES::
806
807
@@ -859,9 +860,9 @@ class WittVectorRing_pinvertible(WittVectorRing):
859
860
"""
860
861
Element = WittVector_pinvertible
861
862
862
- def __init__ (self , coefficient_ring , prec , prime ):
863
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
863
864
r"""
864
- Initialises ``self``.
865
+ Initialise ``self``.
865
866
866
867
EXAMPLES::
867
868
@@ -901,9 +902,9 @@ class WittVectorRing_standard(WittVectorRing):
901
902
"""
902
903
Element = WittVector_standard
903
904
904
- def __init__ (self , coefficient_ring , prec , prime ):
905
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
905
906
r"""
906
- Initialises ``self``.
907
+ Initialise ``self``.
907
908
908
909
EXAMPLES::
909
910
0 commit comments