Skip to content

Commit 6f8a761

Browse files
author
Release Manager
committed
sagemathgh-38622: pep8 fixes in schemes/toric mostly done with `autopep8` for codes `E231,E201,E202` ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: sagemath#38622 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents e02dc78 + d91d631 commit 6f8a761

File tree

4 files changed

+104
-104
lines changed

4 files changed

+104
-104
lines changed

src/sage/schemes/toric/ideal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ def _naive_ideal(self, ring):
354354
x = ring.gens()
355355
binomials = []
356356
for row in self.ker().matrix().rows():
357-
xpos = prod(x[i]**max( row[i],0) for i in range(0,len(x)))
358-
xneg = prod(x[i]**max(-row[i],0) for i in range(0,len(x)))
357+
xpos = prod(x[i]**max(row[i], 0) for i in range(len(x)))
358+
xneg = prod(x[i]**max(-row[i], 0) for i in range(len(x)))
359359
binomials.append(xpos - xneg)
360360
return ring.ideal(binomials)
361361

@@ -445,6 +445,6 @@ def _ideal_HostenSturmfels(self):
445445
J = self._naive_ideal(ring)
446446
if J.is_zero():
447447
return J
448-
for i in range(0,self.nvariables()):
448+
for i in range(self.nvariables()):
449449
J = self._ideal_quotient_by_variable(ring, J, i)
450450
return J

src/sage/schemes/toric/library.py

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -58,44 +58,44 @@
5858
# The combinatorial data of the toric varieties is stored separately here
5959
# since we might want to use it later on to do the reverse lookup.
6060
toric_varieties_rays_cones = {
61-
'dP6':[
61+
'dP6': [
6262
[(0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0), (1, 1)],
63-
[[0,1],[1,2],[2,3],[3,4],[4,5],[5,0]] ],
64-
'dP7':[
63+
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]],
64+
'dP7': [
6565
[(0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0)],
66-
[[0,1],[1,2],[2,3],[3,4],[4,0]] ],
67-
'dP8':[
68-
[(1,1), (0, 1), (-1, -1), (1, 0)],
69-
[[0,1],[1,2],[2,3],[3,0]]
66+
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]],
67+
'dP8': [
68+
[(1, 1), (0, 1), (-1, -1), (1, 0)],
69+
[[0, 1], [1, 2], [2, 3], [3, 0]]
7070
],
71-
'P1xP1':[
71+
'P1xP1': [
7272
[(1, 0), (-1, 0), (0, 1), (0, -1)],
73-
[[0,2],[2,1],[1,3],[3,0]] ],
74-
'P1xP1_Z2':[
73+
[[0, 2], [2, 1], [1, 3], [3, 0]]],
74+
'P1xP1_Z2': [
7575
[(1, 1), (-1, -1), (-1, 1), (1, -1)],
76-
[[0,2],[2,1],[1,3],[3,0]] ],
77-
'P1':[
76+
[[0, 2], [2, 1], [1, 3], [3, 0]]],
77+
'P1': [
7878
[(1,), (-1,)],
79-
[[0],[1]] ],
80-
'P2':[
81-
[(1,0), (0, 1), (-1, -1)],
82-
[[0,1],[1,2],[2,0]] ],
83-
'A1':[
79+
[[0], [1]]],
80+
'P2': [
81+
[(1, 0), (0, 1), (-1, -1)],
82+
[[0, 1], [1, 2], [2, 0]]],
83+
'A1': [
8484
[(1,)],
85-
[[0]] ],
86-
'A2':[
85+
[[0]]],
86+
'A2': [
8787
[(1, 0), (0, 1)],
88-
[[0,1]] ],
89-
'A2_Z2':[
88+
[[0, 1]]],
89+
'A2_Z2': [
9090
[(1, 0), (1, 2)],
91-
[[0,1]] ],
92-
'P1xA1':[
91+
[[0, 1]]],
92+
'P1xA1': [
9393
[(1, 0), (-1, 0), (0, 1)],
94-
[[0,2],[2,1]] ],
95-
'Conifold':[
94+
[[0, 2], [2, 1]]],
95+
'Conifold': [
9696
[(0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)],
97-
[[0,1,2,3]] ],
98-
'dP6xdP6':[
97+
[[0, 1, 2, 3]]],
98+
'dP6xdP6': [
9999
[(0, 1, 0, 0), (-1, 0, 0, 0), (-1, -1, 0, 0),
100100
(0, -1, 0, 0), (1, 0, 0, 0), (1, 1, 0, 0),
101101
(0, 0, 0, 1), (0, 0, -1, 0), (0, 0, -1, -1),
@@ -108,74 +108,74 @@
108108
[3, 4, 8, 9], [3, 4, 9, 10], [3, 4, 10, 11], [3, 4, 6, 11],
109109
[4, 5, 6, 7], [4, 5, 7, 8], [4, 5, 8, 9], [4, 5, 9, 10],
110110
[4, 5, 10, 11], [4, 5, 6, 11], [0, 5, 6, 7], [0, 5, 7, 8],
111-
[0, 5, 8, 9], [0, 5, 9, 10], [0, 5, 10, 11], [0, 5, 6, 11]] ],
112-
'Cube_face_fan':[
111+
[0, 5, 8, 9], [0, 5, 9, 10], [0, 5, 10, 11], [0, 5, 6, 11]]],
112+
'Cube_face_fan': [
113113
[(1, 1, 1), (1, -1, 1), (-1, 1, 1), (-1, -1, 1),
114114
(-1, -1, -1), (-1, 1, -1), (1, -1, -1), (1, 1, -1)],
115-
[[0,1,2,3], [4,5,6,7], [0,1,7,6], [4,5,3,2], [0,2,5,7], [4,6,1,3]] ],
116-
'Cube_sublattice':[
115+
[[0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 7, 6], [4, 5, 3, 2], [0, 2, 5, 7], [4, 6, 1, 3]]],
116+
'Cube_sublattice': [
117117
[(1, 0, 0), (0, 1, 0), (0, 0, 1), (-1, 1, 1),
118118
(-1, 0, 0), (0, -1, 0), (0, 0, -1), (1, -1, -1)],
119-
[[0,1,2,3],[4,5,6,7],[0,1,7,6],[4,5,3,2],[0,2,5,7],[4,6,1,3]] ],
120-
'Cube_nonpolyhedral':[
119+
[[0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 7, 6], [4, 5, 3, 2], [0, 2, 5, 7], [4, 6, 1, 3]]],
120+
'Cube_nonpolyhedral': [
121121
[(1, 2, 3), (1, -1, 1), (-1, 1, 1), (-1, -1, 1),
122122
(-1, -1, -1), (-1, 1, -1), (1, -1, -1), (1, 1, -1)],
123-
[[0,1,2,3],[4,5,6,7],[0,1,7,6],[4,5,3,2],[0,2,5,7],[4,6,1,3]] ],
124-
'BCdlOG':[
123+
[[0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 7, 6], [4, 5, 3, 2], [0, 2, 5, 7], [4, 6, 1, 3]]],
124+
'BCdlOG': [
125125
[(-1, 0, 0, 2, 3), # 0
126-
( 0,-1, 0, 2, 3), # 1
127-
( 0, 0,-1, 2, 3), # 2
128-
( 0, 0,-1, 1, 2), # 3
129-
( 0, 0, 0,-1, 0), # 4
130-
( 0, 0, 0, 0,-1), # 5
131-
( 0, 0, 0, 2, 3), # 6
132-
( 0, 0, 1, 2, 3), # 7
133-
( 0, 0, 2, 2, 3), # 8
134-
( 0, 0, 1, 1, 1), # 9
135-
( 0, 1, 2, 2, 3), # 10
136-
( 0, 1, 3, 2, 3), # 11
137-
( 1, 0, 4, 2, 3)], # 12
138-
[ [0,6,7,1,4], [0,6,10,2,4], [0,6,1,2,4], [0,9,7,1,5], [0,6,7,1,5],
139-
[0,6,10,2,5], [0,6,1,2,5], [0,9,1,4,5], [0,6,10,4,11],[0,6,7,4,11],
140-
[0,6,10,5,11], [0,9,7,5,11], [0,6,7,5,11], [0,9,4,5,11], [0,10,4,5,11],
141-
[0,9,7,1,8], [0,9,1,4,8], [0,7,1,4,8], [0,9,7,11,8], [0,9,4,11,8],
142-
[0,7,4,11,8], [0,10,2,4,3], [0,1,2,4,3], [0,10,2,5,3], [0,1,2,5,3],
143-
[0,10,4,5,3], [0,1,4,5,3], [12,6,7,1,4], [12,6,10,2,4],[12,6,1,2,4],
144-
[12,9,7,1,5], [12,6,7,1,5], [12,6,10,2,5], [12,6,1,2,5], [12,9,1,4,5],
145-
[12,6,10,4,11],[12,6,7,4,11], [12,6,10,5,11],[12,9,7,5,11],[12,6,7,5,11],
146-
[12,9,4,5,11], [12,10,4,5,11],[12,9,7,1,8], [12,9,1,4,8], [12,7,1,4,8],
147-
[12,9,7,11,8], [12,9,4,11,8], [12,7,4,11,8], [12,10,2,4,3],[12,1,2,4,3],
148-
[12,10,2,5,3], [12,1,2,5,3], [12,10,4,5,3], [12,1,4,5,3] ] ],
149-
'BCdlOG_base':[
126+
(0, -1, 0, 2, 3), # 1
127+
(0, 0, -1, 2, 3), # 2
128+
(0, 0, -1, 1, 2), # 3
129+
(0, 0, 0, -1, 0), # 4
130+
(0, 0, 0, 0, -1), # 5
131+
(0, 0, 0, 2, 3), # 6
132+
(0, 0, 1, 2, 3), # 7
133+
(0, 0, 2, 2, 3), # 8
134+
(0, 0, 1, 1, 1), # 9
135+
(0, 1, 2, 2, 3), # 10
136+
(0, 1, 3, 2, 3), # 11
137+
(1, 0, 4, 2, 3)], # 12
138+
[[0, 6, 7, 1, 4], [0, 6, 10, 2, 4], [0, 6, 1, 2, 4], [0, 9, 7, 1, 5], [0, 6, 7, 1, 5],
139+
[0, 6, 10, 2, 5], [0, 6, 1, 2, 5], [0, 9, 1, 4, 5], [0, 6, 10, 4, 11], [0, 6, 7, 4, 11],
140+
[0, 6, 10, 5, 11], [0, 9, 7, 5, 11], [0, 6, 7, 5, 11], [0, 9, 4, 5, 11], [0, 10, 4, 5, 11],
141+
[0, 9, 7, 1, 8], [0, 9, 1, 4, 8], [0, 7, 1, 4, 8], [0, 9, 7, 11, 8], [0, 9, 4, 11, 8],
142+
[0, 7, 4, 11, 8], [0, 10, 2, 4, 3], [0, 1, 2, 4, 3], [0, 10, 2, 5, 3], [0, 1, 2, 5, 3],
143+
[0, 10, 4, 5, 3], [0, 1, 4, 5, 3], [12, 6, 7, 1, 4], [12, 6, 10, 2, 4], [12, 6, 1, 2, 4],
144+
[12, 9, 7, 1, 5], [12, 6, 7, 1, 5], [12, 6, 10, 2, 5], [12, 6, 1, 2, 5], [12, 9, 1, 4, 5],
145+
[12, 6, 10, 4, 11], [12, 6, 7, 4, 11], [12, 6, 10, 5, 11], [12, 9, 7, 5, 11], [12, 6, 7, 5, 11],
146+
[12, 9, 4, 5, 11], [12, 10, 4, 5, 11], [12, 9, 7, 1, 8], [12, 9, 1, 4, 8], [12, 7, 1, 4, 8],
147+
[12, 9, 7, 11, 8], [12, 9, 4, 11, 8], [12, 7, 4, 11, 8], [12, 10, 2, 4, 3], [12, 1, 2, 4, 3],
148+
[12, 10, 2, 5, 3], [12, 1, 2, 5, 3], [12, 10, 4, 5, 3], [12, 1, 4, 5, 3]]],
149+
'BCdlOG_base': [
150150
[(-1, 0, 0),
151-
( 0,-1, 0),
152-
( 0, 0,-1),
153-
( 0, 0, 1),
154-
( 0, 1, 2),
155-
( 0, 1, 3),
156-
( 1, 0, 4)],
157-
[[0,4,2],[0,4,5],[0,5,3],[0,1,3],[0,1,2],
158-
[6,4,2],[6,4,5],[6,5,3],[6,1,3],[6,1,2]] ],
159-
'P2_112':[
160-
[(1,0), (0, 1), (-1, -2)],
161-
[[0,1],[1,2],[2,0]] ],
162-
'P2_123':[
163-
[(1,0), (0, 1), (-2, -3)],
164-
[[0,1],[1,2],[2,0]] ],
165-
'P4_11169':[
151+
(0, -1, 0),
152+
(0, 0, -1),
153+
(0, 0, 1),
154+
(0, 1, 2),
155+
(0, 1, 3),
156+
(1, 0, 4)],
157+
[[0, 4, 2], [0, 4, 5], [0, 5, 3], [0, 1, 3], [0, 1, 2],
158+
[6, 4, 2], [6, 4, 5], [6, 5, 3], [6, 1, 3], [6, 1, 2]]],
159+
'P2_112': [
160+
[(1, 0), (0, 1), (-1, -2)],
161+
[[0, 1], [1, 2], [2, 0]]],
162+
'P2_123': [
163+
[(1, 0), (0, 1), (-2, -3)],
164+
[[0, 1], [1, 2], [2, 0]]],
165+
'P4_11169': [
166166
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-9, -6, -1, -1)],
167-
[[0,1,2,3],[0,1,2,4],[0,1,3,4],[0,2,3,4],[1,2,3,4]] ],
168-
'P4_11169_resolved':[
167+
[[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [1, 2, 3, 4]]],
168+
'P4_11169_resolved': [
169169
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-9, -6, -1, -1), (-3, -2, 0, 0)],
170170
[[0, 1, 2, 3], [0, 1, 3, 4], [0, 1, 2, 4], [1, 3, 4, 5], [0, 3, 4, 5],
171-
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]] ],
172-
'P4_11133':[
171+
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]]],
172+
'P4_11133': [
173173
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-3, -3, -1, -1)],
174-
[[0,1,2,3],[0,1,2,4],[0,1,3,4],[0,2,3,4],[1,2,3,4]] ],
175-
'P4_11133_resolved':[
174+
[[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [1, 2, 3, 4]]],
175+
'P4_11133_resolved': [
176176
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-3, -3, -1, -1), (-1, -1, 0, 0)],
177177
[[0, 1, 2, 3], [0, 1, 3, 4], [0, 1, 2, 4], [1, 3, 4, 5], [0, 3, 4, 5],
178-
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]] ]
178+
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]]]
179179
}
180180

181181

@@ -264,7 +264,7 @@ def _make_CPRFanoToricVariety(self, name, coordinate_names, base_ring):
264264
polytope = LatticePolytope(rays, lattice=ToricLattice(len(rays[0])))
265265
points = [tuple(_) for _ in polytope.points()]
266266
ray2point = [points.index(r) for r in rays]
267-
charts = [ [ray2point[i] for i in c] for c in cones ]
267+
charts = [[ray2point[i] for i in c] for c in cones]
268268
self.__dict__[dict_key] = \
269269
CPRFanoToricVariety(Delta_polar=polytope,
270270
coordinate_points=ray2point,
@@ -868,7 +868,7 @@ def Cube_nonpolyhedral(self, names='z+', base_ring=QQ):
868868
"""
869869
return self._make_ToricVariety('Cube_nonpolyhedral', names, base_ring)
870870

871-
def Cube_deformation(self,k, names=None, base_ring=QQ):
871+
def Cube_deformation(self, k, names=None, base_ring=QQ):
872872
r"""
873873
Construct, for each `k\in\ZZ_{\geq 0}`, a toric variety with
874874
`\ZZ_k`-torsion in the Chow group.
@@ -1268,7 +1268,7 @@ def WP(self, *q, **kw):
12681268
rays = rays + [v]
12691269
w_c = w[:i] + w[i + 1:]
12701270
cones = cones + [tuple(w_c)]
1271-
fan = Fan(cones,rays)
1271+
fan = Fan(cones, rays)
12721272
return ToricVariety(fan, coordinate_names=names, base_ring=base_ring)
12731273

12741274
def torus(self, n, names='z+', base_ring=QQ):

src/sage/schemes/toric/sheaf/klyachko.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def cohomology_complex(self, m):
605605
C = fan.complex()
606606
CV = []
607607
F = self.base_ring()
608-
for dim in range(1,fan.dim()+1):
608+
for dim in range(1, fan.dim()+1):
609609
codim = fan.dim() - dim
610610
d_C = C.differential(codim)
611611
d_V = []
@@ -616,7 +616,7 @@ def cohomology_complex(self, m):
616616
sigma = fan(dim-1)[i]
617617
if sigma.is_face_of(tau):
618618
pr = self.E_quotient_projection(sigma, tau, m)
619-
d = d_C[i,j] * pr.matrix().transpose()
619+
d = d_C[i, j] * pr.matrix().transpose()
620620
else:
621621
E_sigma = self.E_quotient(sigma, m)
622622
E_tau = self.E_quotient(tau, m)
@@ -695,7 +695,7 @@ def cohomology(self, degree=None, weight=None, dim=False):
695695
except KeyError:
696696
HH[d] = FreeModule(self.base_ring(), 0)
697697
if dim:
698-
HH = vector(ZZ, [HH[i].rank() for i in range(space_dim+1) ])
698+
HH = vector(ZZ, [HH[i].rank() for i in range(space_dim+1)])
699699
return HH
700700

701701
def __richcmp__(self, other, op):

src/sage/schemes/toric/toric_subscheme.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,14 @@ def pullback_polynomial(p):
328328
result = R.zero()
329329
for coefficient, monomial in p:
330330
exponent = monomial.exponents()[0]
331-
exponent = [ exponent[i] for i in cone.ambient_ray_indices() ]
332-
exponent = vector(ZZ,exponent)
331+
exponent = [exponent[i] for i in cone.ambient_ray_indices()]
332+
exponent = vector(ZZ, exponent)
333333
m = n_rho_matrix.solve_right(exponent)
334334
assert all(x in ZZ for x in m), \
335-
'The polynomial '+str(p)+' does not define a ZZ-divisor!'
335+
f'The polynomial {p} does not define a ZZ-divisor!'
336336
m_coeffs = dualcone.Hilbert_coefficients(m)
337337
result += coefficient * prod(R.gen(i)**m_coeffs[i]
338-
for i in range(0,R.ngens()))
338+
for i in range(R.ngens()))
339339
return result
340340

341341
# construct the affine algebraic scheme to use as patch
@@ -353,7 +353,7 @@ def pullback_polynomial(p):
353353
if cone.is_smooth():
354354
x = ambient.coordinate_ring().gens()
355355
phi = []
356-
for i in range(0,fan.nrays()):
356+
for i in range(fan.nrays()):
357357
if i in cone.ambient_ray_indices():
358358
phi.append(pullback_polynomial(x[i]))
359359
else:
@@ -371,11 +371,10 @@ def pullback_polynomial(p):
371371
# it remains to find the preimage of point
372372
# map m to the monomial x^{D_m}, see reference.
373373
F = ambient.coordinate_ring().fraction_field()
374-
image = []
375-
for m in dualcone.Hilbert_basis():
376-
x_Dm = prod([ F.gen(i)**(m*n) for i,n in enumerate(fan.rays()) ])
377-
image.append(x_Dm)
378-
patch._embedding_center = tuple( f(list(point)) for f in image )
374+
image = [prod([F.gen(i)**(m * n)
375+
for i, n in enumerate(fan.rays())])
376+
for m in dualcone.Hilbert_basis()]
377+
patch._embedding_center = tuple(f(list(point)) for f in image)
379378
return patch
380379

381380
def _best_affine_patch(self, point):
@@ -487,7 +486,7 @@ def neighborhood(self, point):
487486
phi_reduced = [S(t) for t in phi]
488487

489488
patch._embedding_center = patch(point_preimage)
490-
patch._embedding_morphism = patch.hom(phi_reduced,self)
489+
patch._embedding_morphism = patch.hom(phi_reduced, self)
491490
return patch
492491

493492
def dimension(self):
@@ -513,7 +512,7 @@ def dimension(self):
513512
if '_dimension' in self.__dict__:
514513
return self._dimension
515514
npatches = self.ambient_space().fan().ngenerating_cones()
516-
dims = [ self.affine_patch(i).dimension() for i in range(0,npatches) ]
515+
dims = [self.affine_patch(i).dimension() for i in range(npatches)]
517516
self._dimension = max(dims)
518517
return self._dimension
519518

@@ -582,7 +581,8 @@ def is_smooth(self, point=None):
582581
if '_smooth' in self.__dict__:
583582
return self._smooth
584583
npatches = self.ambient_space().fan().ngenerating_cones()
585-
self._smooth = all(self.affine_patch(i).is_smooth() for i in range(0,npatches))
584+
self._smooth = all(self.affine_patch(i).is_smooth()
585+
for i in range(npatches))
586586
return self._smooth
587587

588588
def is_nondegenerate(self):
@@ -692,7 +692,7 @@ def restrict(cone):
692692
enumerate(SR.subs(divide).gens())])
693693
return ideal, Jac_patch + SR_patch
694694

695-
for dim in range(0, fan.dim() + 1):
695+
for dim in range(fan.dim() + 1):
696696
for cone in fan(dim):
697697
ideal1, ideal2 = restrict(cone)
698698
if ideal1.is_zero() or ideal2.dimension() != -1:

0 commit comments

Comments
 (0)