Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pep8 fixes in schemes/toric #38622

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sage/schemes/toric/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def _naive_ideal(self, ring):
x = ring.gens()
binomials = []
for row in self.ker().matrix().rows():
xpos = prod(x[i]**max( row[i],0) for i in range(0,len(x)))
xneg = prod(x[i]**max(-row[i],0) for i in range(0,len(x)))
xpos = prod(x[i]**max(row[i], 0) for i in range(len(x)))
xneg = prod(x[i]**max(-row[i], 0) for i in range(len(x)))
binomials.append(xpos - xneg)
return ring.ideal(binomials)

Expand Down Expand Up @@ -445,6 +445,6 @@ def _ideal_HostenSturmfels(self):
J = self._naive_ideal(ring)
if J.is_zero():
return J
for i in range(0,self.nvariables()):
for i in range(self.nvariables()):
J = self._ideal_quotient_by_variable(ring, J, i)
return J
168 changes: 84 additions & 84 deletions src/sage/schemes/toric/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,44 @@
# The combinatorial data of the toric varieties is stored separately here
# since we might want to use it later on to do the reverse lookup.
toric_varieties_rays_cones = {
'dP6':[
'dP6': [
[(0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0), (1, 1)],
[[0,1],[1,2],[2,3],[3,4],[4,5],[5,0]] ],
'dP7':[
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]],
'dP7': [
[(0, 1), (-1, 0), (-1, -1), (0, -1), (1, 0)],
[[0,1],[1,2],[2,3],[3,4],[4,0]] ],
'dP8':[
[(1,1), (0, 1), (-1, -1), (1, 0)],
[[0,1],[1,2],[2,3],[3,0]]
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]],
'dP8': [
[(1, 1), (0, 1), (-1, -1), (1, 0)],
[[0, 1], [1, 2], [2, 3], [3, 0]]
],
'P1xP1':[
'P1xP1': [
[(1, 0), (-1, 0), (0, 1), (0, -1)],
[[0,2],[2,1],[1,3],[3,0]] ],
'P1xP1_Z2':[
[[0, 2], [2, 1], [1, 3], [3, 0]]],
'P1xP1_Z2': [
[(1, 1), (-1, -1), (-1, 1), (1, -1)],
[[0,2],[2,1],[1,3],[3,0]] ],
'P1':[
[[0, 2], [2, 1], [1, 3], [3, 0]]],
'P1': [
[(1,), (-1,)],
[[0],[1]] ],
'P2':[
[(1,0), (0, 1), (-1, -1)],
[[0,1],[1,2],[2,0]] ],
'A1':[
[[0], [1]]],
'P2': [
[(1, 0), (0, 1), (-1, -1)],
[[0, 1], [1, 2], [2, 0]]],
'A1': [
[(1,)],
[[0]] ],
'A2':[
[[0]]],
'A2': [
[(1, 0), (0, 1)],
[[0,1]] ],
'A2_Z2':[
[[0, 1]]],
'A2_Z2': [
[(1, 0), (1, 2)],
[[0,1]] ],
'P1xA1':[
[[0, 1]]],
'P1xA1': [
[(1, 0), (-1, 0), (0, 1)],
[[0,2],[2,1]] ],
'Conifold':[
[[0, 2], [2, 1]]],
'Conifold': [
[(0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)],
[[0,1,2,3]] ],
'dP6xdP6':[
[[0, 1, 2, 3]]],
'dP6xdP6': [
[(0, 1, 0, 0), (-1, 0, 0, 0), (-1, -1, 0, 0),
(0, -1, 0, 0), (1, 0, 0, 0), (1, 1, 0, 0),
(0, 0, 0, 1), (0, 0, -1, 0), (0, 0, -1, -1),
Expand All @@ -108,74 +108,74 @@
[3, 4, 8, 9], [3, 4, 9, 10], [3, 4, 10, 11], [3, 4, 6, 11],
[4, 5, 6, 7], [4, 5, 7, 8], [4, 5, 8, 9], [4, 5, 9, 10],
[4, 5, 10, 11], [4, 5, 6, 11], [0, 5, 6, 7], [0, 5, 7, 8],
[0, 5, 8, 9], [0, 5, 9, 10], [0, 5, 10, 11], [0, 5, 6, 11]] ],
'Cube_face_fan':[
[0, 5, 8, 9], [0, 5, 9, 10], [0, 5, 10, 11], [0, 5, 6, 11]]],
'Cube_face_fan': [
[(1, 1, 1), (1, -1, 1), (-1, 1, 1), (-1, -1, 1),
(-1, -1, -1), (-1, 1, -1), (1, -1, -1), (1, 1, -1)],
[[0,1,2,3], [4,5,6,7], [0,1,7,6], [4,5,3,2], [0,2,5,7], [4,6,1,3]] ],
'Cube_sublattice':[
[[0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 7, 6], [4, 5, 3, 2], [0, 2, 5, 7], [4, 6, 1, 3]]],
'Cube_sublattice': [
[(1, 0, 0), (0, 1, 0), (0, 0, 1), (-1, 1, 1),
(-1, 0, 0), (0, -1, 0), (0, 0, -1), (1, -1, -1)],
[[0,1,2,3],[4,5,6,7],[0,1,7,6],[4,5,3,2],[0,2,5,7],[4,6,1,3]] ],
'Cube_nonpolyhedral':[
[[0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 7, 6], [4, 5, 3, 2], [0, 2, 5, 7], [4, 6, 1, 3]]],
'Cube_nonpolyhedral': [
[(1, 2, 3), (1, -1, 1), (-1, 1, 1), (-1, -1, 1),
(-1, -1, -1), (-1, 1, -1), (1, -1, -1), (1, 1, -1)],
[[0,1,2,3],[4,5,6,7],[0,1,7,6],[4,5,3,2],[0,2,5,7],[4,6,1,3]] ],
'BCdlOG':[
[[0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 7, 6], [4, 5, 3, 2], [0, 2, 5, 7], [4, 6, 1, 3]]],
'BCdlOG': [
[(-1, 0, 0, 2, 3), # 0
( 0,-1, 0, 2, 3), # 1
( 0, 0,-1, 2, 3), # 2
( 0, 0,-1, 1, 2), # 3
( 0, 0, 0,-1, 0), # 4
( 0, 0, 0, 0,-1), # 5
( 0, 0, 0, 2, 3), # 6
( 0, 0, 1, 2, 3), # 7
( 0, 0, 2, 2, 3), # 8
( 0, 0, 1, 1, 1), # 9
( 0, 1, 2, 2, 3), # 10
( 0, 1, 3, 2, 3), # 11
( 1, 0, 4, 2, 3)], # 12
[ [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],
[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],
[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],
[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],
[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],
[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],
[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],
[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],
[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],
[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],
[12,10,2,5,3], [12,1,2,5,3], [12,10,4,5,3], [12,1,4,5,3] ] ],
'BCdlOG_base':[
(0, -1, 0, 2, 3), # 1
(0, 0, -1, 2, 3), # 2
(0, 0, -1, 1, 2), # 3
(0, 0, 0, -1, 0), # 4
(0, 0, 0, 0, -1), # 5
(0, 0, 0, 2, 3), # 6
(0, 0, 1, 2, 3), # 7
(0, 0, 2, 2, 3), # 8
(0, 0, 1, 1, 1), # 9
(0, 1, 2, 2, 3), # 10
(0, 1, 3, 2, 3), # 11
(1, 0, 4, 2, 3)], # 12
[[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],
[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],
[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],
[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],
[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],
[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],
[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],
[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],
[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],
[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],
[12, 10, 2, 5, 3], [12, 1, 2, 5, 3], [12, 10, 4, 5, 3], [12, 1, 4, 5, 3]]],
'BCdlOG_base': [
[(-1, 0, 0),
( 0,-1, 0),
( 0, 0,-1),
( 0, 0, 1),
( 0, 1, 2),
( 0, 1, 3),
( 1, 0, 4)],
[[0,4,2],[0,4,5],[0,5,3],[0,1,3],[0,1,2],
[6,4,2],[6,4,5],[6,5,3],[6,1,3],[6,1,2]] ],
'P2_112':[
[(1,0), (0, 1), (-1, -2)],
[[0,1],[1,2],[2,0]] ],
'P2_123':[
[(1,0), (0, 1), (-2, -3)],
[[0,1],[1,2],[2,0]] ],
'P4_11169':[
(0, -1, 0),
(0, 0, -1),
(0, 0, 1),
(0, 1, 2),
(0, 1, 3),
(1, 0, 4)],
[[0, 4, 2], [0, 4, 5], [0, 5, 3], [0, 1, 3], [0, 1, 2],
[6, 4, 2], [6, 4, 5], [6, 5, 3], [6, 1, 3], [6, 1, 2]]],
'P2_112': [
[(1, 0), (0, 1), (-1, -2)],
[[0, 1], [1, 2], [2, 0]]],
'P2_123': [
[(1, 0), (0, 1), (-2, -3)],
[[0, 1], [1, 2], [2, 0]]],
'P4_11169': [
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-9, -6, -1, -1)],
[[0,1,2,3],[0,1,2,4],[0,1,3,4],[0,2,3,4],[1,2,3,4]] ],
'P4_11169_resolved':[
[[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [1, 2, 3, 4]]],
'P4_11169_resolved': [
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-9, -6, -1, -1), (-3, -2, 0, 0)],
[[0, 1, 2, 3], [0, 1, 3, 4], [0, 1, 2, 4], [1, 3, 4, 5], [0, 3, 4, 5],
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]] ],
'P4_11133':[
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]]],
'P4_11133': [
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-3, -3, -1, -1)],
[[0,1,2,3],[0,1,2,4],[0,1,3,4],[0,2,3,4],[1,2,3,4]] ],
'P4_11133_resolved':[
[[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [1, 2, 3, 4]]],
'P4_11133_resolved': [
[(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (-3, -3, -1, -1), (-1, -1, 0, 0)],
[[0, 1, 2, 3], [0, 1, 3, 4], [0, 1, 2, 4], [1, 3, 4, 5], [0, 3, 4, 5],
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]] ]
[1, 2, 4, 5], [0, 2, 4, 5], [1, 2, 3, 5], [0, 2, 3, 5]]]
}


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

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

def torus(self, n, names='z+', base_ring=QQ):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/schemes/toric/sheaf/klyachko.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def cohomology_complex(self, m):
C = fan.complex()
CV = []
F = self.base_ring()
for dim in range(1,fan.dim()+1):
for dim in range(1, fan.dim()+1):
codim = fan.dim() - dim
d_C = C.differential(codim)
d_V = []
Expand All @@ -616,7 +616,7 @@ def cohomology_complex(self, m):
sigma = fan(dim-1)[i]
if sigma.is_face_of(tau):
pr = self.E_quotient_projection(sigma, tau, m)
d = d_C[i,j] * pr.matrix().transpose()
d = d_C[i, j] * pr.matrix().transpose()
else:
E_sigma = self.E_quotient(sigma, m)
E_tau = self.E_quotient(tau, m)
Expand Down Expand Up @@ -695,7 +695,7 @@ def cohomology(self, degree=None, weight=None, dim=False):
except KeyError:
HH[d] = FreeModule(self.base_ring(), 0)
if dim:
HH = vector(ZZ, [HH[i].rank() for i in range(space_dim+1) ])
HH = vector(ZZ, [HH[i].rank() for i in range(space_dim+1)])
return HH

def __richcmp__(self, other, op):
Expand Down
28 changes: 14 additions & 14 deletions src/sage/schemes/toric/toric_subscheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ def pullback_polynomial(p):
result = R.zero()
for coefficient, monomial in p:
exponent = monomial.exponents()[0]
exponent = [ exponent[i] for i in cone.ambient_ray_indices() ]
exponent = vector(ZZ,exponent)
exponent = [exponent[i] for i in cone.ambient_ray_indices()]
exponent = vector(ZZ, exponent)
m = n_rho_matrix.solve_right(exponent)
assert all(x in ZZ for x in m), \
'The polynomial '+str(p)+' does not define a ZZ-divisor!'
f'The polynomial {p} does not define a ZZ-divisor!'
m_coeffs = dualcone.Hilbert_coefficients(m)
result += coefficient * prod(R.gen(i)**m_coeffs[i]
for i in range(0,R.ngens()))
for i in range(R.ngens()))
return result

# construct the affine algebraic scheme to use as patch
Expand All @@ -353,7 +353,7 @@ def pullback_polynomial(p):
if cone.is_smooth():
x = ambient.coordinate_ring().gens()
phi = []
for i in range(0,fan.nrays()):
for i in range(fan.nrays()):
if i in cone.ambient_ray_indices():
phi.append(pullback_polynomial(x[i]))
else:
Expand All @@ -371,11 +371,10 @@ def pullback_polynomial(p):
# it remains to find the preimage of point
# map m to the monomial x^{D_m}, see reference.
F = ambient.coordinate_ring().fraction_field()
image = []
for m in dualcone.Hilbert_basis():
x_Dm = prod([ F.gen(i)**(m*n) for i,n in enumerate(fan.rays()) ])
image.append(x_Dm)
patch._embedding_center = tuple( f(list(point)) for f in image )
image = [prod([F.gen(i)**(m * n)
for i, n in enumerate(fan.rays())])
for m in dualcone.Hilbert_basis()]
patch._embedding_center = tuple(f(list(point)) for f in image)
return patch

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

patch._embedding_center = patch(point_preimage)
patch._embedding_morphism = patch.hom(phi_reduced,self)
patch._embedding_morphism = patch.hom(phi_reduced, self)
return patch

def dimension(self):
Expand All @@ -513,7 +512,7 @@ def dimension(self):
if '_dimension' in self.__dict__:
return self._dimension
npatches = self.ambient_space().fan().ngenerating_cones()
dims = [ self.affine_patch(i).dimension() for i in range(0,npatches) ]
dims = [self.affine_patch(i).dimension() for i in range(npatches)]
self._dimension = max(dims)
return self._dimension

Expand Down Expand Up @@ -582,7 +581,8 @@ def is_smooth(self, point=None):
if '_smooth' in self.__dict__:
return self._smooth
npatches = self.ambient_space().fan().ngenerating_cones()
self._smooth = all(self.affine_patch(i).is_smooth() for i in range(0,npatches))
self._smooth = all(self.affine_patch(i).is_smooth()
for i in range(npatches))
return self._smooth

def is_nondegenerate(self):
Expand Down Expand Up @@ -692,7 +692,7 @@ def restrict(cone):
enumerate(SR.subs(divide).gens())])
return ideal, Jac_patch + SR_patch

for dim in range(0, fan.dim() + 1):
for dim in range(fan.dim() + 1):
for cone in fan(dim):
ideal1, ideal2 = restrict(cone)
if ideal1.is_zero() or ideal2.dimension() != -1:
Expand Down
Loading