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
28
+ from sage .categories .integral_domains import IntegralDomains
29
29
from sage .categories .fields import Fields
30
30
from sage .misc .latex import latex
31
31
from sage .rings .integer import Integer
42
42
from sage .rings .polynomial .polynomial_element import Polynomial
43
43
from sage .rings .polynomial .polynomial_ring import PolynomialRing_generic
44
44
from sage .rings .polynomial .polynomial_ring_constructor import PolynomialRing
45
- from sage .rings . ring import CommutativeRing
45
+ from sage .structure . parent import Parent
46
46
from sage .sets .primes import Primes
47
47
from sage .structure .unique_representation import UniqueRepresentation
48
48
49
49
50
50
def fast_char_p_power (x , n , p = None ):
51
51
r"""
52
- Return `x^n` assuming that `x` lives in a ring of
53
- characteristic `p`.
52
+ Return `x^n` assuming that `x` lives in a ring of characteristic `p`.
54
53
55
54
If `x` is not an element of a ring of characteristic `p`,
56
55
this throws an error.
@@ -120,7 +119,7 @@ def fast_char_p_power(x, n, p=None):
120
119
return xn
121
120
122
121
123
- class WittVectorRing (CommutativeRing , UniqueRepresentation ):
122
+ class WittVectorRing (Parent , UniqueRepresentation ):
124
123
r"""
125
124
Return the appropriate `p`-typical truncated Witt vector ring.
126
125
@@ -263,27 +262,32 @@ def __classcall_private__(cls, coefficient_ring, prec=1, p=None, algorithm=None)
263
262
264
263
return child .__classcall__ (child , coefficient_ring , prec , p )
265
264
266
- def __init__ (self , coefficient_ring , prec , prime ):
265
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
267
266
r"""
268
- Initialises ``self``.
267
+ Initialise ``self``.
269
268
270
269
EXAMPLES::
271
270
272
- sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4)
273
- sage: W
271
+ sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4); W
274
272
Ring of truncated 5-typical Witt vectors of length 4 over Univariate Polynomial Ring in t over Finite Field of size 5
275
273
sage: type(W)
276
274
<class 'sage.rings.padics.witt_vector_ring.WittVectorRing_phantom_with_category'>
277
275
278
276
sage: TestSuite(W).run()
279
277
"""
280
- self ._coefficient_ring = coefficient_ring
278
+ cring = coefficient_ring
279
+ self ._coefficient_ring = cring
281
280
self ._prec = prec
282
281
self ._prime = prime
283
282
284
- CommutativeRing .__init__ (self , self )
283
+ if prec == 1 and cring in IntegralDomains ():
284
+ cat = IntegralDomains ()
285
+ else :
286
+ cat = CommutativeRings ()
285
287
286
- def __iter__ (self ):
288
+ Parent .__init__ (self , base = ZZ , category = cat )
289
+
290
+ def __iter__ (self ) -> Iterator :
287
291
"""
288
292
Iterator for truncated Witt vector rings.
289
293
@@ -347,7 +351,7 @@ def _coerce_map_from_(self, S):
347
351
if (isinstance (S , WittVectorRing )
348
352
and S .precision () >= self ._prec and S .prime () == self ._prime
349
353
and self ._coefficient_ring .has_coerce_map_from (
350
- S .coefficient_ring ())):
354
+ S .coefficient_ring ())):
351
355
return (any (isinstance (S , rng ) for rng in self ._always_coerce )
352
356
or (S .precision () != self ._prec
353
357
or S .coefficient_ring () is not self ._coefficient_ring )
@@ -358,7 +362,7 @@ def _coerce_map_from_(self, S):
358
362
359
363
def _generate_sum_and_product_polynomials (self , coefficient_ring , prec , p ):
360
364
"""
361
- Generates the sum and product polynomials defining the ring laws of
365
+ Generate the sum and product polynomials defining the ring laws of
362
366
truncated Witt vectors for the ``standard`` algorithm.
363
367
364
368
EXAMPLES::
@@ -387,7 +391,7 @@ def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
387
391
#
388
392
# Remark: Since when is SIXTEEN bits sufficient for anyone???
389
393
#
390
- if p ** (prec - 1 ) >= 2 ** 16 :
394
+ if p ** (prec - 1 ) >= 2 ** 16 :
391
395
implementation = 'generic'
392
396
else :
393
397
implementation = 'singular'
@@ -421,7 +425,7 @@ def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
421
425
self ._sum_polynomials [n ] = S (self ._sum_polynomials [n ])
422
426
self ._prod_polynomials [n ] = S (self ._prod_polynomials [n ])
423
427
424
- def _latex_ (self ):
428
+ def _latex_ (self ) -> str :
425
429
r"""
426
430
Return a `\LaTeX` representation of ``self``.
427
431
@@ -439,7 +443,7 @@ def _latex_(self):
439
443
return "W_{%s}\\ left(%s\\ right)" % (latex (self ._prec ),
440
444
latex (self ._coefficient_ring ))
441
445
442
- def _repr_ (self ):
446
+ def _repr_ (self ) -> str :
443
447
"""
444
448
Return a string representation of the ring.
445
449
@@ -498,7 +502,7 @@ def coefficient_ring(self):
498
502
"""
499
503
return self ._coefficient_ring
500
504
501
- def is_finite (self ):
505
+ def is_finite (self ) -> bool :
502
506
"""
503
507
Return whether ``self`` is a finite ring.
504
508
@@ -572,7 +576,9 @@ def prod_polynomials(self, variables=None):
572
576
573
577
def random_element (self , * args , ** kwds ):
574
578
"""
575
- Return a random truncated Witt vector. Extra arguments are passed to
579
+ Return a random truncated Witt vector.
580
+
581
+ Extra arguments are passed to
576
582
the random generator of the coefficient ring.
577
583
578
584
EXAMPLES::
@@ -621,8 +627,9 @@ def sum_polynomials(self, variables=None):
621
627
622
628
def teichmuller_lift (self , x ):
623
629
"""
624
- Return the Teichmüller lift of ``x`` in ``self``. This lift is
625
- sometimes known as the multiplicative lift of ``x``.
630
+ Return the Teichmüller lift of ``x`` in ``self``.
631
+
632
+ This lift is sometimes known as the multiplicative lift of ``x``.
626
633
627
634
EXAMPLES::
628
635
@@ -656,9 +663,9 @@ class WittVectorRing_finotti(WittVectorRing):
656
663
"""
657
664
Element = WittVector_finotti
658
665
659
- def __init__ (self , coefficient_ring , prec , prime ):
666
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
660
667
r"""
661
- Initialises ``self``.
668
+ Initialise ``self``.
662
669
663
670
EXAMPLES::
664
671
@@ -798,9 +805,9 @@ class WittVectorRing_phantom(WittVectorRing):
798
805
"""
799
806
Element = WittVector_phantom
800
807
801
- def __init__ (self , coefficient_ring , prec , prime ):
808
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
802
809
r"""
803
- Initialises ``self``.
810
+ Initialise ``self``.
804
811
805
812
EXAMPLES::
806
813
@@ -859,9 +866,9 @@ class WittVectorRing_pinvertible(WittVectorRing):
859
866
"""
860
867
Element = WittVector_pinvertible
861
868
862
- def __init__ (self , coefficient_ring , prec , prime ):
869
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
863
870
r"""
864
- Initialises ``self``.
871
+ Initialise ``self``.
865
872
866
873
EXAMPLES::
867
874
@@ -901,9 +908,9 @@ class WittVectorRing_standard(WittVectorRing):
901
908
"""
902
909
Element = WittVector_standard
903
910
904
- def __init__ (self , coefficient_ring , prec , prime ):
911
+ def __init__ (self , coefficient_ring , prec , prime ) -> None :
905
912
r"""
906
- Initialises ``self``.
913
+ Initialise ``self``.
907
914
908
915
EXAMPLES::
909
916
0 commit comments