Skip to content

Commit 7a62c96

Browse files
committed
fix
1 parent a55615c commit 7a62c96

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/sage/geometry/lattice_polytope.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
from sage.structure.richcmp import richcmp_method, richcmp
143143
from sage.geometry.convex_set import ConvexSet_compact
144144
import sage.geometry.abc
145-
from sage.matrix.permuted_matrix_window import PermutedMatrixWindow
146145

147146
from copy import copy
148147
from collections.abc import Hashable
@@ -3210,7 +3209,7 @@ def index_of_max(iterable):
32103209
return m
32113210

32123211
n_s = 1
3213-
permutations_inv = {0 : [S_f.one(), S_v.one()]}
3212+
permutations_inv = {0: [S_f.one(), S_v.one()]}
32143213
for j in range(n_v):
32153214
m = index_of_max([PM[0][i] for i in range(j, n_v)])
32163215
if m > 0:
@@ -3221,23 +3220,23 @@ def index_of_max(iterable):
32213220
for k in range(1, n_f):
32223221
# Error for k == 1 already!
32233222
permutations_inv[n_s] = [S_f.one(), S_v.one()]
3224-
m = index_of_max(PM[k, tuple((permutations_inv[n_s][1])(j+1)-1 for j in range(n_v))])
3223+
m = index_of_max(PM[k, tuple(permutations_inv[n_s][1](j+1) - 1 for j in range(n_v))])
32253224
if m > 0:
32263225
permutations_inv[n_s][1] = permutations_inv[n_s][1] * PGE(S_v, 1, m+1)
3227-
d = (PM[k, (permutations_inv[n_s][1])(1)-1]
3226+
d = (PM[k, permutations_inv[n_s][1](1) - 1]
32283227
- (permutations_inv[0][1].inverse())(first_row)[0])
32293228
if d < 0:
32303229
# The largest elt of this row is smaller than largest elt
32313230
# in 1st row, so nothing to do
32323231
continue
32333232
# otherwise:
32343233
for i in range(1, n_v):
3235-
m = index_of_max(PM[k, tuple((permutations_inv[n_s][1])(j+1)-1 for j in range(i,n_v))])
3234+
m = index_of_max(PM[k, tuple(permutations_inv[n_s][1](j+1) - 1 for j in range(i,n_v))])
32363235
if m > 0:
32373236
permutations_inv[n_s][1] = permutations_inv[n_s][1] \
32383237
* PGE(S_v, i + 1, m + i + 1)
32393238
if d == 0:
3240-
d = (PM[k, (permutations_inv[n_s][1])(i+1)-1]
3239+
d = (PM[k, permutations_inv[n_s][1](i+1) - 1]
32413240
-(permutations_inv[0][1].inverse())(first_row)[i])
32423241
if d < 0:
32433242
break
@@ -3255,9 +3254,9 @@ def index_of_max(iterable):
32553254
first_row = list(PM[k])
32563255
permutations_inv = {0: permutations_inv[n_s]}
32573256
n_s = 1
3258-
permutations_inv = {k:permutations_inv[k] for k in permutations_inv if k < n_s}
3257+
permutations_inv = {k: permutations_inv[k] for k in permutations_inv if k < n_s}
32593258

3260-
b = tuple(PM[(permutations_inv[0][0])(1)-1, (permutations_inv[0][1])(j+1)-1] for j in range(n_v))
3259+
b = tuple(PM[permutations_inv[0][0](1) - 1, permutations_inv[0][1](j+1) - 1] for j in range(n_v))
32613260
# Work out the restrictions the current permutations
32623261
# place on other permutations as a automorphisms
32633262
# of the first row
@@ -3291,17 +3290,17 @@ def index_of_max(iterable):
32913290
# between 0 and S(0)
32923291
for s in range(l, n_f):
32933292
for j in range(1, S[0]):
3294-
v = tuple(PM[(permutations_inv_bar[n_p][0])(s+1)-1, (permutations_inv_bar[n_p][1])(j+1)-1] for j in range(n_v))
3293+
v = tuple(PM[permutations_inv_bar[n_p][0](s+1) - 1, permutations_inv_bar[n_p][1](j+1) - 1] for j in range(n_v))
32953294
if v[0] < v[j]:
32963295
permutations_inv_bar[n_p][1] = permutations_inv_bar[n_p][1] * PGE(S_v, 1, j + 1)
32973296
if ccf == 0:
3298-
l_r[0] = PM[(permutations_inv_bar[n_p][0])(s+1)-1, (permutations_inv_bar[n_p][1])(1)-1]
3297+
l_r[0] = PM[permutations_inv_bar[n_p][0](s+1) - 1, permutations_inv_bar[n_p][1](1) - 1]
32993298
permutations_inv_bar[n_p][0] = permutations_inv_bar[n_p][0] * PGE(S_f, l + 1, s + 1)
33003299
n_p += 1
33013300
ccf = 1
33023301
permutations_inv_bar[n_p] = copy(permutations_inv[k])
33033302
else:
3304-
d1 = PM[(permutations_inv_bar[n_p][0])(s+1)-1, (permutations_inv_bar[n_p][1])(1)-1]
3303+
d1 = PM[permutations_inv_bar[n_p][0](s+1) - 1, permutations_inv_bar[n_p][1](1) - 1]
33053304
d = d1 - l_r[0]
33063305
if d < 0:
33073306
# We move to the next line
@@ -3337,15 +3336,15 @@ def index_of_max(iterable):
33373336
s -= 1
33383337
# Find the largest value in this symmetry block
33393338
for j in range(c + 1, h):
3340-
v = tuple(PM[(permutations_inv_bar[s][0])(l+1)-1, (permutations_inv_bar[s][1])(j+1)-1] for j in range(n_v))
3339+
v = tuple(PM[(permutations_inv_bar[s][0])(l+1) - 1, (permutations_inv_bar[s][1])(j+1) - 1] for j in range(n_v))
33413340
if (v[c] < v[j]):
33423341
permutations_inv_bar[s][1] = permutations_inv_bar[s][1] * PGE(S_v, c + 1, j + 1)
33433342
if ccf == 0:
33443343
# Set reference and carry on to next permutation
3345-
l_r[c] = PM[(permutations_inv_bar[s][0])(l+1)-1, (permutations_inv_bar[s][1])(c+1)-1]
3344+
l_r[c] = PM[(permutations_inv_bar[s][0])(l+1) - 1, (permutations_inv_bar[s][1])(c+1) - 1]
33463345
ccf = 1
33473346
else:
3348-
d1 = PM[(permutations_inv_bar[s][0])(l+1)-1, (permutations_inv_bar[s][1])(c+1)-1]
3347+
d1 = PM[(permutations_inv_bar[s][0])(l+1) - 1, (permutations_inv_bar[s][1])(c+1) - 1]
33493348
d = d1 - l_r[c]
33503349
if d < 0:
33513350
n_p -= 1
@@ -3374,7 +3373,7 @@ def index_of_max(iterable):
33743373
# the restrictions the last worked out
33753374
# row imposes.
33763375
c = 0
3377-
M = tuple(PM[(permutations_inv[0][0])(l+1)-1, (permutations_inv[0][1])(j+1)-1] for j in range(n_v))
3376+
M = tuple(PM[permutations_inv[0][0](l+1) - 1, permutations_inv[0][1](j+1) - 1] for j in range(n_v))
33783377
while c < n_v:
33793378
s = S[c] + 1
33803379
S[c] = c + 1
@@ -3387,12 +3386,9 @@ def index_of_max(iterable):
33873386
S[c] = c + 1
33883387
c += 1
33893388
# Now we have the perms, we construct PM_max using one of them
3390-
PM_max = PM.with_permuted_rows_and_columns(permutations_inv[0][0].inverse(),permutations_inv[0][1].inverse())
3389+
PM_max = PM.with_permuted_rows_and_columns(permutations_inv[0][0].inverse(), permutations_inv[0][1].inverse())
33913390
if check:
3392-
for p in permutations_inv.keys():
3393-
permutations_inv[p][0] = permutations_inv[p][0].inverse()
3394-
permutations_inv[p][1] = permutations_inv[p][1].inverse()
3395-
return (PM_max, permutations_inv)
3391+
return (PM_max, {p: [permutations_inv[p][0].inverse(),permutations_inv[p][1].inverse()] for p in permutations_inv.keys()})
33963392
else:
33973393
return PM_max
33983394

0 commit comments

Comments
 (0)