63
63
64
64
from sage .arith .functions import lcm
65
65
from sage .arith .misc import bernoulli , kronecker , factor , gcd , fundamental_discriminant , euler_phi , valuation
66
+ from sage .arith .misc import binomial , factorial
66
67
from sage .categories .map import Map
67
68
from sage .categories .objects import Objects
68
- from sage .functions .other import binomial , factorial
69
69
from sage .libs .pari import pari
70
70
from sage .misc .cachefunc import cached_method
71
71
from sage .misc .fast_methods import WithEqualityById
75
75
from sage .rings .finite_rings .integer_mod import Mod
76
76
from sage .rings .finite_rings .integer_mod_ring import IntegerModRing
77
77
from sage .rings .integer import Integer
78
- from sage .rings .integer_ring import ZZ
79
78
from sage .rings .number_field .number_field import CyclotomicField , NumberField , NumberField_generic
80
79
from sage .rings .power_series_ring import PowerSeriesRing
81
- from sage .rings .rational_field import RationalField , QQ , is_RationalField
80
+ from sage .rings .rational_field import QQ , is_RationalField
82
81
from sage .rings .ring import is_Ring
83
82
from sage .structure .element import MultiplicativeGroupElement
84
83
from sage .structure .factory import UniqueFactory
88
87
from sage .structure .sequence import Sequence
89
88
90
89
91
- def trivial_character (N , base_ring = RationalField () ):
90
+ def trivial_character (N , base_ring = QQ ):
92
91
r"""
93
92
Return the trivial character of the given modulus, with values in the given
94
93
base ring.
@@ -135,14 +134,14 @@ def kronecker_character(d):
135
134
raise ValueError ("d must be nonzero" )
136
135
137
136
D = fundamental_discriminant (d )
138
- G = DirichletGroup (abs (D ), RationalField () )
137
+ G = DirichletGroup (abs (D ), QQ )
139
138
return G ([kronecker (D , u ) for u in G .unit_gens ()])
140
139
141
140
142
141
def kronecker_character_upside_down (d ):
143
142
"""
144
143
Return the quadratic Dirichlet character (./d) of conductor d, for
145
- d0 .
144
+ d > 0 .
146
145
147
146
EXAMPLES::
148
147
@@ -157,11 +156,11 @@ def kronecker_character_upside_down(d):
157
156
if d <= 0 :
158
157
raise ValueError ("d must be positive" )
159
158
160
- G = DirichletGroup (d , RationalField () )
159
+ G = DirichletGroup (d , QQ )
161
160
return G ([kronecker (u .lift (), d ) for u in G .unit_gens ()])
162
161
163
162
164
- def is_DirichletCharacter (x ):
163
+ def is_DirichletCharacter (x ) -> bool :
165
164
r"""
166
165
Return ``True`` if ``x`` is of type ``DirichletCharacter``.
167
166
@@ -639,7 +638,7 @@ def bernoulli(self, k, algorithm='recurrence', cache=True, **opts):
639
638
.. MATH::
640
639
641
640
\sum_{a=1}^N \frac{\varepsilon(a) t e^{at}}{e^{Nt}-1}
642
- = sum_{k=0}^{\infty} \frac{B_{k,\varepsilon}}{k!} t^k.
641
+ = \ sum_{k=0}^{\infty} \frac{B_{k,\varepsilon}}{k!} t^k.
643
642
644
643
ALGORITHM:
645
644
@@ -707,8 +706,9 @@ def bernoulli(self, k, algorithm='recurrence', cache=True, **opts):
707
706
708
707
def S (n ):
709
708
return sum (v [r ] * r ** n for r in range (1 , N ))
710
- ber = K (sum (binomial (k , j ) * bernoulli (j , ** opts ) *
711
- N ** (j - 1 ) * S (k - j ) for j in range (k + 1 )))
709
+
710
+ ber = sum (binomial (k , j ) * bernoulli (j , ** opts ) *
711
+ N ** (j - 1 ) * S (k - j ) for j in range (k + 1 ))
712
712
elif algorithm == "definition" :
713
713
# This is better since it computes the same thing, but requires
714
714
# no arith in a poly ring over a number field.
@@ -721,7 +721,7 @@ def S(n):
721
721
h = [0 ] + [g * ((n * t ).exp (prec )) for n in range (1 , N + 1 )]
722
722
ber = sum ([self (a ) * h [a ][k ] for a in range (1 , N + 1 )]) * factorial (k )
723
723
else :
724
- raise ValueError ("algorithm = '%s ' unknown" % algorithm )
724
+ raise ValueError (f "algorithm = '{ algorithm } ' unknown" )
725
725
726
726
if cache :
727
727
self .__bernoulli [k ] = ber
@@ -998,7 +998,7 @@ def fixed_field_polynomial(self, algorithm="pari"):
998
998
G , chi = self ._pari_init_ ()
999
999
K = pari .charker (G , chi )
1000
1000
H = pari .galoissubcyclo (G , K )
1001
- P = PolynomialRing (RationalField () , "x" )
1001
+ P = PolynomialRing (QQ , "x" )
1002
1002
x = P .gen ()
1003
1003
return H .sage ({"x" : x })
1004
1004
@@ -2943,7 +2943,7 @@ def _automorphisms(self):
2943
2943
if p == 0 :
2944
2944
Auts = [e for e in range (1 , n ) if gcd (e , n ) == 1 ]
2945
2945
else :
2946
- if not ZZ (p ).is_prime ():
2946
+ if not Integer (p ).is_prime ():
2947
2947
raise NotImplementedError ("Automorphisms for finite non-field base rings not implemented" )
2948
2948
# The automorphisms in characteristic p are
2949
2949
# k-th powering for
0 commit comments