@@ -194,11 +194,11 @@ def __init__(self, parent, polys, check=True):
194
194
"""
195
195
if check :
196
196
if not isinstance (polys , (list , tuple )):
197
- raise TypeError ("polys (=%s) must be a list or tuple" % polys )
197
+ raise TypeError ("polys (=%s) must be a list or tuple" % polys )
198
198
source_ring = parent .domain ().ambient_space ().coordinate_ring ()
199
199
target = parent .codomain ().ambient_space ()
200
200
if len (polys ) != target .ngens ():
201
- raise ValueError ("there must be %s polynomials" % target .ngens ())
201
+ raise ValueError ("there must be %s polynomials" % target .ngens ())
202
202
try :
203
203
polys = [source_ring (poly ) for poly in polys ]
204
204
except TypeError : # maybe given quotient ring elements
@@ -207,14 +207,15 @@ def __init__(self, parent, polys, check=True):
207
207
except (TypeError , AttributeError ):
208
208
# must be a rational function since we cannot have
209
209
# rational functions for quotient rings
210
+ source_field = source_ring .base_ring ().fraction_field ()
210
211
try :
211
- if not all (p .base_ring ().fraction_field ()== source_ring . base_ring (). fraction_field () for p in polys ):
212
- raise TypeError ("polys (=%s) must be rational functions in %s" % (polys , source_ring ))
212
+ if not all (p .base_ring ().fraction_field () == source_field for p in polys ):
213
+ raise TypeError ("polys (=%s) must be rational functions in %s" % (polys , source_ring ))
213
214
K = FractionField (source_ring )
214
215
polys = [K (p ) for p in polys ]
215
216
# polys = [source_ring(poly.numerator())/source_ring(poly.denominator()) for poly in polys]
216
- except TypeError : # can't seem to coerce
217
- raise TypeError ("polys (=%s) must be rational functions in %s" % (polys , source_ring ))
217
+ except TypeError : # can't seem to coerce
218
+ raise TypeError ("polys (=%s) must be rational functions in %s" % (polys , source_ring ))
218
219
check = False
219
220
220
221
SchemeMorphism_polynomial .__init__ (self , parent , polys , check )
@@ -263,7 +264,7 @@ def __call__(self, x, check=True):
263
264
try :
264
265
x = self .domain ()(x )
265
266
except (TypeError , NotImplementedError ):
266
- raise TypeError ("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (x , self .domain ()))
267
+ raise TypeError ("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (x , self .domain ()))
267
268
268
269
R = x .domain ().coordinate_ring ()
269
270
if R is self .base_ring ():
@@ -307,7 +308,7 @@ def __eq__(self, right):
307
308
return False
308
309
if self .parent () != right .parent ():
309
310
return False
310
- return all (val == right ._polys [i ] for i ,val in enumerate (self ._polys ))
311
+ return all (val == right ._polys [i ] for i , val in enumerate (self ._polys ))
311
312
312
313
def __ne__ (self , right ):
313
314
"""
@@ -336,7 +337,7 @@ def __ne__(self, right):
336
337
return True
337
338
if self .parent () != right .parent ():
338
339
return True
339
- return any (val != right ._polys [i ] for i ,val in enumerate (self ._polys ))
340
+ return any (val != right ._polys [i ] for i , val in enumerate (self ._polys ))
340
341
341
342
@lazy_attribute
342
343
def _fastpolys (self ):
@@ -422,11 +423,11 @@ def _fast_eval(self, x):
422
423
P = []
423
424
for i in range (len (self ._fastpolys [0 ])):
424
425
# Check if denominator is the identity;
425
- #if not, then must append the fraction evaluated at the point
426
+ # if not, then must append the fraction evaluated at the point
426
427
if self ._fastpolys [1 ][i ] is R .one ():
427
428
P .append (self ._fastpolys [0 ][i ](* x ))
428
429
else :
429
- P .append (self ._fastpolys [0 ][i ](* x )/ self ._fastpolys [1 ][i ](* x ))
430
+ P .append (self ._fastpolys [0 ][i ](* x ) / self ._fastpolys [1 ][i ](* x ))
430
431
return P
431
432
432
433
def homogenize (self , n ):
@@ -597,32 +598,32 @@ def homogenize(self, n):
597
598
# create dictionary for mapping of coordinate rings
598
599
R = self .domain ().ambient_space ().coordinate_ring ()
599
600
S = A .ambient_space ().coordinate_ring ()
600
- D = dict (zip (R .gens (), [S .gen (i ) for i in range (N + 1 ) if i != ind [0 ]]))
601
+ D = dict (zip (R .gens (), [S .gen (i ) for i in range (N + 1 ) if i != ind [0 ]]))
601
602
602
603
if self .codomain ().is_projective ():
603
- L = [self [i ].denominator () for i in range (M + 1 )]
604
- l = [prod (L [:j ] + L [j + 1 :M + 1 ]) for j in range (M + 1 )]
605
- F = [S (R (self [i ].numerator ()* l [i ]).subs (D )) for i in range (M + 1 )]
604
+ L = [self [i ].denominator () for i in range (M + 1 )]
605
+ l = [prod (L [:j ] + L [j + 1 :M + 1 ]) for j in range (M + 1 )]
606
+ F = [S (R (self [i ].numerator () * l [i ]).subs (D )) for i in range (M + 1 )]
606
607
else :
607
608
# clear the denominators if a rational function
608
609
L = [self [i ].denominator () for i in range (M )]
609
- l = [prod (L [:j ] + L [j + 1 :M ]) for j in range (M )]
610
- F = [S (R (self [i ].numerator ()* l [i ]).subs (D )) for i in range (M )]
610
+ l = [prod (L [:j ] + L [j + 1 :M ]) for j in range (M )]
611
+ F = [S (R (self [i ].numerator () * l [i ]).subs (D )) for i in range (M )]
611
612
F .insert (ind [1 ], S (R (prod (L )).subs (D ))) # coerce in case l is a constant
612
613
613
614
try :
614
615
# remove possible gcd of the polynomials
615
616
g = gcd (F )
616
- F = [S (f / g ) for f in F ]
617
+ F = [S (f / g ) for f in F ]
617
618
# remove possible gcd of coefficients
618
619
gc = gcd ([f .content () for f in F ])
619
- F = [S (f / gc ) for f in F ]
620
- except (AttributeError , ValueError , NotImplementedError , TypeError , ArithmeticError ): # no gcd
620
+ F = [S (f / gc ) for f in F ]
621
+ except (AttributeError , ValueError , NotImplementedError , TypeError , ArithmeticError ): # no gcd
621
622
pass
622
623
623
624
# homogenize
624
- d = max ([F [i ].degree () for i in range (M + 1 )])
625
- F = [F [i ].homogenize (str (newvar ))* newvar ** (d - F [i ].degree ()) for i in range (M + 1 )]
625
+ d = max ([F [i ].degree () for i in range (M + 1 )])
626
+ F = [F [i ].homogenize (str (newvar )) * newvar ** (d - F [i ].degree ()) for i in range (M + 1 )]
626
627
627
628
return H (F )
628
629
@@ -678,7 +679,7 @@ def as_dynamical_system(self):
678
679
if R not in _Fields :
679
680
return DynamicalSystem_affine (list (self ), self .domain ())
680
681
if isinstance (R , FiniteField ):
681
- return DynamicalSystem_affine_finite_field (list (self ), self .domain ())
682
+ return DynamicalSystem_affine_finite_field (list (self ), self .domain ())
682
683
return DynamicalSystem_affine_field (list (self ), self .domain ())
683
684
684
685
def global_height (self , prec = None ):
@@ -885,7 +886,7 @@ def jacobian(self):
885
886
return self .__jacobian
886
887
except AttributeError :
887
888
pass
888
- self .__jacobian = jacobian (list (self ),self .domain ().ambient_space ().gens ())
889
+ self .__jacobian = jacobian (list (self ), self .domain ().ambient_space ().gens ())
889
890
return self .__jacobian
890
891
891
892
def _matrix_times_polymap_ (self , mat , h ):
@@ -1025,6 +1026,7 @@ def degree(self):
1025
1026
max_degree = poly .degree ()
1026
1027
return max_degree
1027
1028
1029
+
1028
1030
class SchemeMorphism_polynomial_affine_space_field (SchemeMorphism_polynomial_affine_space ):
1029
1031
1030
1032
@cached_method
@@ -1210,7 +1212,7 @@ def reduce_base_field(self):
1210
1212
R = new_domain .coordinate_ring ()
1211
1213
H = Hom (new_domain , new_codomain )
1212
1214
if isinstance (g [0 ], FractionFieldElement ):
1213
- return H ([R (G .numerator ())/ R (G .denominator ()) for G in g ])
1215
+ return H ([R (G .numerator ()) / R (G .denominator ()) for G in g ])
1214
1216
return H ([R (G ) for G in g ])
1215
1217
1216
1218
def indeterminacy_locus (self ):
@@ -1241,7 +1243,7 @@ def indeterminacy_locus(self):
1241
1243
"""
1242
1244
A = self .domain ()
1243
1245
X = A .subscheme (0 ) # affine space as a subscheme
1244
- return (self * X .hom (A .gens (), A )).indeterminacy_locus ()
1246
+ return (self * X .hom (A .gens (), A )).indeterminacy_locus ()
1245
1247
1246
1248
def indeterminacy_points (self , F = None ):
1247
1249
r"""
@@ -1316,7 +1318,7 @@ def image(self):
1316
1318
"""
1317
1319
X = self .domain ().subscheme (0 )
1318
1320
e = X .embedding_morphism ()
1319
- return (self * e ).image ()
1321
+ return (self * e ).image ()
1320
1322
1321
1323
1322
1324
class SchemeMorphism_polynomial_affine_space_finite_field (SchemeMorphism_polynomial_affine_space_field ):
@@ -1342,7 +1344,7 @@ def _fast_eval(self, x):
1342
1344
[1, 1, 2]
1343
1345
"""
1344
1346
R = self .domain ().ambient_space ().coordinate_ring ()
1345
- P = []
1347
+ P = []
1346
1348
for i in range (len (self ._fastpolys [0 ])):
1347
1349
r = self ._fastpolys [0 ][i ](* x )
1348
1350
if self ._fastpolys [1 ][i ] is R .one ():
@@ -1356,7 +1358,7 @@ def _fast_eval(self, x):
1356
1358
p = self .base_ring ().characteristic ()
1357
1359
r = Integer (r ) % p
1358
1360
s = Integer (s ) % p
1359
- P .append (r / s )
1361
+ P .append (r / s )
1360
1362
return P
1361
1363
1362
1364
@@ -1441,7 +1443,7 @@ def representatives(self):
1441
1443
reprs = []
1442
1444
for r in h .representatives ():
1443
1445
i = X .projective_embedding (0 , h .domain ().ambient_space ())
1444
- reprs .append (r * i )
1446
+ reprs .append (r * i )
1445
1447
else :
1446
1448
reprs = []
1447
1449
for r in h .representatives ():
@@ -1563,5 +1565,5 @@ def image(self):
1563
1565
return self .homogenize (0 ).image ()
1564
1566
1565
1567
e = Y .projective_embedding (0 )
1566
- h = (e * self ).homogenize (0 )
1568
+ h = (e * self ).homogenize (0 )
1567
1569
return h .image ().affine_patch (0 , Y .ambient_space ())
0 commit comments