Skip to content

Commit 4215fe7

Browse files
committed
cylint cleanup in geometry
1 parent 665a3fa commit 4215fe7

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed

src/sage/geometry/integral_points.pxi

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,33 @@ from sage.modules.free_module import FreeModule
3232
# full-dimensional case, the Smith normal form takes care of that for
3333
# you.
3434
#
35-
## def parallelotope_points(spanning_points, lattice):
36-
## # compute points in the open parallelotope, see [BK2001]
37-
## R = matrix(spanning_points).transpose()
38-
## D,U,V = R.smith_form()
39-
## e = D.diagonal() # the elementary divisors
40-
## d = prod(e) # the determinant
41-
## u = U.inverse().columns() # generators for gp(semigroup)
42-
##
43-
## # "inverse" of the ray matrix as far as possible over ZZ
44-
## # R*Rinv == diagonal_matrix([d]*D.ncols() + [0]*(D.nrows()-D.ncols()))
45-
## # If R is full rank, this is Rinv = matrix(ZZ, R.inverse() * d)
46-
## Dinv = D.transpose()
47-
## for i in range(D.ncols()):
48-
## Dinv[i,i] = d/D[i,i]
49-
## Rinv = V * Dinv * U
50-
##
51-
## gens = []
52-
## for b in CartesianProduct(*[ range(i) for i in e ]):
53-
## # this is our generator modulo the lattice spanned by the rays
54-
## gen_mod_rays = sum( b_i*u_i for b_i, u_i in zip(b,u) )
55-
## q_times_d = Rinv * gen_mod_rays
56-
## q_times_d = vector(ZZ,[ q_i % d for q_i in q_times_d ])
57-
## gen = lattice(R*q_times_d / d)
58-
## gen.set_immutable()
59-
## gens.append(gen)
60-
## assert(len(gens) == d)
61-
## return tuple(gens)
35+
# def parallelotope_points(spanning_points, lattice):
36+
# # compute points in the open parallelotope, see [BK2001]
37+
# R = matrix(spanning_points).transpose()
38+
# D,U,V = R.smith_form()
39+
# e = D.diagonal() # the elementary divisors
40+
# d = prod(e) # the determinant
41+
# u = U.inverse().columns() # generators for gp(semigroup)
42+
#
43+
# # "inverse" of the ray matrix as far as possible over ZZ
44+
# # R*Rinv == diagonal_matrix([d]*D.ncols() + [0]*(D.nrows()-D.ncols()))
45+
# # If R is full rank, this is Rinv = matrix(ZZ, R.inverse() * d)
46+
# Dinv = D.transpose()
47+
# for i in range(D.ncols()):
48+
# Dinv[i,i] = d/D[i,i]
49+
# Rinv = V * Dinv * U
50+
#
51+
# gens = []
52+
# for b in CartesianProduct(*[range(i) for i in e]):
53+
# # this is our generator modulo the lattice spanned by the rays
54+
# gen_mod_rays = sum(b_i*u_i for b_i, u_i in zip(b,u))
55+
# q_times_d = Rinv * gen_mod_rays
56+
# q_times_d = vector(ZZ, [q_i % d for q_i in q_times_d])
57+
# gen = lattice(R*q_times_d / d)
58+
# gen.set_immutable()
59+
# gens.append(gen)
60+
# assert(len(gens) == d)
61+
# return tuple(gens)
6262
#
6363
# The problem with the naive implementation is that it is slow:
6464
#
@@ -115,7 +115,7 @@ cpdef tuple parallelotope_points(spanning_points, lattice):
115115
116116
A non-smooth cone::
117117
118-
sage: c = Cone([ (1,0), (1,2) ])
118+
sage: c = Cone([(1,0), (1,2)])
119119
sage: parallelotope_points(c.rays(), c.lattice())
120120
(N(0, 0), N(1, 1))
121121
@@ -162,13 +162,13 @@ cpdef tuple ray_matrix_normal_form(R):
162162
sage: ray_matrix_normal_form(R)
163163
([3], 3, [1])
164164
"""
165-
D,U,V = R.smith_form()
165+
D, U, V = R.smith_form()
166166
e = D.diagonal() # the elementary divisors
167167
cdef Integer d = prod(e) # the determinant
168168
if d == ZZ.zero():
169169
raise ValueError('The spanning points are not linearly independent!')
170170
cdef int i
171-
Dinv = diagonal_matrix(ZZ, [ d // e[i] for i in range(D.ncols()) ])
171+
Dinv = diagonal_matrix(ZZ, [d // e[i] for i in range(D.ncols())])
172172
VDinv = V * Dinv
173173
return (e, d, VDinv)
174174

@@ -212,20 +212,20 @@ cpdef tuple loop_over_parallelotope_points(e, d, MatrixClass VDinv,
212212
cdef int i, j
213213
cdef int dim = VDinv.nrows()
214214
cdef int ambient_dim = R.nrows()
215-
s = ZZ.zero() # summation variable
215+
s = ZZ.zero() # summation variable
216216
cdef list gens = []
217217
gen = lattice(ZZ.zero())
218218
cdef VectorClass q_times_d = vector(ZZ, dim)
219-
for base in itertools.product(*[ range(i) for i in e ]):
219+
for base in itertools.product(*[range(i) for i in e]):
220220
for i in range(dim):
221221
s = ZZ.zero()
222222
for j in range(dim):
223-
s += VDinv.get_unsafe(i,j) * base[j]
223+
s += VDinv.get_unsafe(i, j) * base[j]
224224
q_times_d.set_unsafe(i, s % d)
225225
for i in range(ambient_dim):
226226
s = ZZ.zero()
227227
for j in range(dim):
228-
s += R.get_unsafe(i,j) * q_times_d.get_unsafe(j)
228+
s += R.get_unsafe(i, j) * q_times_d.get_unsafe(j)
229229
gen[i] = s / d
230230
if A is not None:
231231
s = ZZ.zero()
@@ -572,7 +572,7 @@ cpdef rectangular_box_points(list box_min, list box_max,
572572
v.set_unsafe(i, Integer(p[orig_perm[i]]))
573573
v_copy = copy.copy(v)
574574
v_copy.set_immutable()
575-
points.append( (v_copy, saturated) )
575+
points.append((v_copy, saturated))
576576

577577
return tuple(points)
578578

@@ -694,7 +694,7 @@ cdef loop_over_rectangular_box_points_saturated(list box_min, list box_max,
694694
while i <= i_max:
695695
p[0] = i
696696
saturated = inequalities.satisfied_as_equalities(i)
697-
points.append( (tuple(p), saturated) )
697+
points.append((tuple(p), saturated))
698698
i += 1
699699
# finally increment the other entries in p to move on to next inner loop
700700
inc = 1
@@ -917,8 +917,8 @@ cdef class Inequality_int:
917917
if self.dim > 0:
918918
self.coeff_next = self.A[1]
919919
# finally, make sure that there cannot be any overflow during the enumeration
920-
self._to_int(abs(ZZ(b)) + sum( abs(ZZ(A[i])) * ZZ(max_abs_coordinates[i])
921-
for i in range(self.dim) ))
920+
self._to_int(abs(ZZ(b)) + sum(abs(ZZ(A[i])) * ZZ(max_abs_coordinates[i])
921+
for i in range(self.dim)))
922922

923923
def __repr__(self):
924924
"""
@@ -1131,7 +1131,7 @@ cdef class InequalityCollection:
11311131
"""
11321132
cdef list A
11331133
cdef int index
1134-
for index,c in enumerate(polyhedron.minimized_constraints()):
1134+
for index, c in enumerate(polyhedron.minimized_constraints()):
11351135
A = perm_action(permutation, [Integer(mpz) for mpz in c.coefficients()])
11361136
b = Integer(c.inhomogeneous_term())
11371137
try:
@@ -1141,7 +1141,7 @@ cdef class InequalityCollection:
11411141
H = Inequality_generic(A, b, index)
11421142
self.ineqs_generic.append(H)
11431143
if c.is_equality():
1144-
A = [ -a for a in A ]
1144+
A = [-a for a in A]
11451145
b = -b
11461146
try:
11471147
H = Inequality_int(A, b, max_abs_coordinates, index)
@@ -1194,7 +1194,7 @@ cdef class InequalityCollection:
11941194
H = Inequality_generic(A, b, Hrep_obj.index())
11951195
self.ineqs_generic.append(H)
11961196
# add sign-reversed inequality
1197-
A = [ -a for a in A ]
1197+
A = [-a for a in A]
11981198
b = -b
11991199
try:
12001200
H = Inequality_int(A, b, max_abs_coordinates, Hrep_obj.index())
@@ -1310,7 +1310,7 @@ cdef class InequalityCollection:
13101310
"""
13111311
i_th_entry = self.ineqs_int[i]
13121312
cdef int j
1313-
for j in range(i-1,-1,-1):
1313+
for j in range(i-1, -1, -1):
13141314
self.ineqs_int[j+1] = self.ineqs_int[j]
13151315
self.ineqs_int[0] = i_th_entry
13161316

@@ -1389,12 +1389,12 @@ cdef class InequalityCollection:
13891389
sig_check()
13901390
ineq = self.ineqs_int[i]
13911391
if (<Inequality_int>ineq).is_equality(inner_loop_variable):
1392-
result.append( (<Inequality_int>ineq).index )
1392+
result.append((<Inequality_int>ineq).index)
13931393
for i in range(len(self.ineqs_generic)):
13941394
sig_check()
13951395
ineq = self.ineqs_generic[i]
13961396
if (<Inequality_generic>ineq).is_equality(inner_loop_variable):
1397-
result.append( (<Inequality_generic>ineq).index )
1397+
result.append((<Inequality_generic>ineq).index)
13981398
return frozenset(result)
13991399

14001400

src/sage/geometry/point_collection.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,13 +986,13 @@ def read_palp_point_collection(f, lattice=None, permutation=False):
986986
# Typical situation: a point on each line
987987
lattice = lattice or ToricLattice(n).dual()
988988
points = [lattice.element_class(lattice, f.readline().split())
989-
for i in range(m)]
989+
for i in range(m)]
990990
else:
991991
# Also may appear as PALP output, e.g. points of 3-d polytopes
992992
lattice = lattice or ToricLattice(m).dual()
993993
data = [f.readline().split() for j in range(m)]
994994
points = [lattice.element_class(lattice, [data[j][i] for j in range(m)])
995-
for i in range(n)]
995+
for i in range(n)]
996996
for p in points:
997997
p.set_immutable()
998998
pc = PointCollection(points, lattice)

src/sage/geometry/toric_lattice_element.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ Or you can create a homomorphism from one lattice to any other::
8585
# The "tutorial" above is a truncated version of one in toric_lattice.py.
8686

8787

88-
#*****************************************************************************
88+
# ***************************************************************************
8989
# Copyright (C) 2010 Andrey Novoseltsev <[email protected]>
9090
# Copyright (C) 2010 William Stein <[email protected]>
9191
#
9292
# Distributed under the terms of the GNU General Public License (GPL)
9393
#
94-
# http://www.gnu.org/licenses/
95-
#*****************************************************************************
94+
# https://www.gnu.org/licenses/
95+
# ***************************************************************************
9696

9797
from sage.libs.gmp.mpz cimport *
9898

0 commit comments

Comments
 (0)