Skip to content

Commit ff0b614

Browse files
author
Release Manager
committed
gh-40222: pep8 cleanup for KR tableaux so mostly only trivial changes ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40222 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents a1f9934 + 94a4da8 commit ff0b614

File tree

1 file changed

+49
-47
lines changed

1 file changed

+49
-47
lines changed

src/sage/combinat/rigged_configurations/kr_tableaux.py

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
J. Algebraic Combinatorics, **37** (2013). 571-599. :arxiv:`1109.3523`.
2626
"""
2727

28-
#*****************************************************************************
28+
# ***************************************************************************
2929
# Copyright (C) 2012 Travis Scrimshaw <[email protected]>
3030
#
3131
# Distributed under the terms of the GNU General Public License (GPL)
@@ -37,8 +37,8 @@
3737
#
3838
# The full text of the GPL is available at:
3939
#
40-
# http://www.gnu.org/licenses/
41-
#*****************************************************************************
40+
# https://www.gnu.org/licenses/
41+
# ***************************************************************************
4242

4343
# This contains both the parent and element classes. These should be split if
4444
# the classes grow larger.
@@ -56,9 +56,11 @@
5656
from sage.combinat.root_system.cartan_type import CartanType
5757
from sage.combinat.crystals.tensor_product import CrystalOfWords
5858
from sage.combinat.crystals.tensor_product import TensorProductOfRegularCrystalsElement
59-
from sage.combinat.crystals.kirillov_reshetikhin import horizontal_dominoes_removed, \
60-
KashiwaraNakashimaTableaux, KirillovReshetikhinGenericCrystalElement, \
61-
partitions_in_box, vertical_dominoes_removed
59+
from sage.combinat.crystals.kirillov_reshetikhin import (
60+
horizontal_dominoes_removed,
61+
KashiwaraNakashimaTableaux, KirillovReshetikhinGenericCrystalElement,
62+
partitions_in_box, vertical_dominoes_removed
63+
)
6264
from sage.combinat.partition import Partition
6365
from sage.combinat.tableau import Tableau
6466

@@ -256,25 +258,25 @@ def __classcall_private__(cls, cartan_type, r, s):
256258
if typ == 'E':
257259
return KRTableauxTypeFromRC(ct, r, s)
258260
else:
259-
if typ == 'BC': # A_{2n}^{(2)}
261+
if typ == 'BC': # A_{2n}^{(2)}
260262
return KRTableauxTypeBox(ct, r, s)
261263
typ = ct.dual().type()
262-
if typ == 'BC': # A_{2n}^{(2)\dagger}
264+
if typ == 'BC': # A_{2n}^{(2)\dagger}
263265
return KRTableauxTypeHorizonal(ct, r, s)
264-
if typ == 'B': # A_{2n-1}^{(2)}
266+
if typ == 'B': # A_{2n-1}^{(2)}
265267
return KRTableauxTypeVertical(ct, r, s)
266-
if typ == 'C': # D_{n+1}^{(2)}
268+
if typ == 'C': # D_{n+1}^{(2)}
267269
if r == ct.dual().classical().rank():
268270
return KRTableauxDTwistedSpin(ct, r, s)
269271
return KRTableauxTypeBox(ct, r, s)
270-
#if typ == 'F': # E_6^{(2)}
271-
if typ == 'G': # D_4^{(3)}
272+
# if typ == 'F': # E_6^{(2)}
273+
if typ == 'G': # D_4^{(3)}
272274
if r == 1:
273275
return KRTableauxTypeBox(ct, r, s)
274276
return KRTableauxTypeFromRC(ct, r, s)
275277

276278
raise NotImplementedError
277-
#return super(KirillovReshetikhinTableaux, cls).__classcall__(cls, ct, r, s)
279+
# return super(KirillovReshetikhinTableaux, cls).__classcall__(cls, ct, r, s)
278280

279281
def __init__(self, cartan_type, r, s):
280282
r"""
@@ -309,7 +311,7 @@ def _repr_(self):
309311
Kirillov-Reshetikhin tableaux of type ['A', 4, 1] and shape (2, 3)
310312
"""
311313
return "Kirillov-Reshetikhin tableaux of type {} and shape ({}, {})".format(
312-
self._cartan_type, self._r, self._s)
314+
self._cartan_type, self._r, self._s)
313315

314316
def __iter__(self):
315317
"""
@@ -324,9 +326,10 @@ def __iter__(self):
324326
"""
325327
index_set = self._cartan_type.classical().index_set()
326328
from sage.sets.recursively_enumerated_set import RecursivelyEnumeratedSet
327-
return RecursivelyEnumeratedSet(self.module_generators,
328-
lambda x: [x.f(i) for i in index_set],
329-
structure='graded').breadth_first_search_iterator()
329+
rset = RecursivelyEnumeratedSet(self.module_generators,
330+
lambda x: [x.f(i) for i in index_set],
331+
structure='graded')
332+
return rset.breadth_first_search_iterator()
330333

331334
def module_generator(self, i=None, **options):
332335
r"""
@@ -378,7 +381,7 @@ def module_generator(self, i=None, **options):
378381
shape = list(options["shape"])
379382
# Make sure the shape is the correct length
380383
if len(shape) < n:
381-
shape.extend( [0]*(n - len(shape)) )
384+
shape.extend([0] * (n - len(shape)))
382385
for mg in self.module_generators:
383386
if list(mg.classical_weight().to_vector()) == shape:
384387
return mg
@@ -387,7 +390,7 @@ def module_generator(self, i=None, **options):
387390
if "column_shape" in options:
388391
shape = list(Partition(options["column_shape"]).conjugate())
389392
if len(shape) < n:
390-
shape.extend( [0]*(n - len(shape)) )
393+
shape.extend([0] * (n - len(shape)))
391394
for mg in self.module_generators:
392395
if list(mg.classical_weight().to_vector()) == shape:
393396
return mg
@@ -412,7 +415,7 @@ def module_generator(self, i=None, **options):
412415
Lambda = R.fundamental_weights()
413416
r = self.r()
414417
s = self.s()
415-
weight = s*Lambda[r] - s*Lambda[0] * Lambda[r].level() / Lambda[0].level()
418+
weight = s * Lambda[r] - s * Lambda[0] * Lambda[r].level() / Lambda[0].level()
416419
for b in self.module_generators:
417420
if b.weight() == weight:
418421
return b
@@ -462,7 +465,7 @@ def _element_constructor_(self, *lst, **options):
462465
if isinstance(lst[0], KirillovReshetikhinGenericCrystalElement):
463466
# Check to make sure it can be converted
464467
if lst[0].cartan_type() != self.cartan_type() \
465-
or lst[0].parent().r() != self._r or lst[0].parent().s() != self._s:
468+
or lst[0].parent().r() != self._r or lst[0].parent().s() != self._s:
466469
raise ValueError("the Kirillov-Reshetikhin crystal must have the same Cartan type and (r,s)")
467470
return self.from_kirillov_reshetikhin_crystal(lst[0])
468471

@@ -544,7 +547,7 @@ def tensor(self, *crystals, **options):
544547
"""
545548
ct = self._cartan_type
546549
from sage.combinat.rigged_configurations.tensor_product_kr_tableaux \
547-
import TensorProductOfKirillovReshetikhinTableaux
550+
import TensorProductOfKirillovReshetikhinTableaux
548551
if all(isinstance(B, (KirillovReshetikhinTableaux, TensorProductOfKirillovReshetikhinTableaux))
549552
and B.cartan_type() == ct for B in crystals):
550553
dims = [[self._r, self._s]]
@@ -601,9 +604,8 @@ def _build_module_generators(self):
601604
sage: KRT._build_module_generators()
602605
([[1, 1, 1], [2, 2, 2]],)
603606
"""
604-
tableau = []
605-
for i in range(self._s):
606-
tableau.append( [self._r - j for j in range(self._r)] )
607+
tableau = [[self._r - j for j in range(self._r)]
608+
for i in range(self._s)]
607609

608610
return (self.element_class(self, [self.letters(x) for x in flatten(tableau)]),)
609611

@@ -670,39 +672,39 @@ def _fill(self, weight):
670672
[[1, 1, 1, 1, 1, 5, 1], [2, 2, 2, 2, 2, 6, 2], [3, 3, 9, 7, 9, 7, 3], [4, 4, 10, 8, 10, 8, 4], [5, 5, 11, 9, 11, 9, 5], [6, 6, 12, 10, 12, 10, 6], [7, 7, -12, 11, -12, 11, 7], [8, 8, -11, 12, -11, 12, 8], [9, 9, -10, -12, -10, -12, -8], [10, 10, -9, -11, -9, -11, -7], [-12, 11, -8, -10, -8, -10, -6], [-11, 12, -7, -9, -7, -9, -5]]
671673
"""
672674
# Add zeros until the shape has length s
673-
weight_list = list(weight) # Make sure we have a list
675+
weight_list = list(weight) # Make sure we have a list
674676
while len(weight_list) != self._s:
675677
weight_list.append(0)
676678

677679
tableau = []
678680
i = 0
679681
# Step 0 - Fill first columns of height r
680682
while i < self._s and weight_list[i] == self._r:
681-
tableau.append( [self._r - j for j in range(self._r)] )
683+
tableau.append([self._r - j for j in range(self._r)])
682684
i += 1
683685

684686
# Step 1 - Add the alternating columns until we hit an odd number of columns
685687
c = -1
686688
while i < self._s:
687689
# If it is an odd number of columns
688-
if i == self._s - 1 or weight_list[i] != weight_list[i+1]:
690+
if i == self._s - 1 or weight_list[i] != weight_list[i + 1]:
689691
c = weight_list[i]
690692
i += 1
691693
break
692694
temp_list = [-(weight_list[i] + j + 1) for j in range(self._r - weight_list[i])]
693695
for j in range(weight_list[i]):
694696
temp_list.append(weight_list[i] - j)
695697
tableau.append(temp_list)
696-
tableau.append( [self._r - j for j in range(self._r)] )
698+
tableau.append([self._r - j for j in range(self._r)])
697699
i += 2
698700

699701
# Step 2 - Add the x dependent columns
700702
x = c + 1
701703
while i < self._s:
702-
temp_list = [-x - j for j in range(self._r - x + 1)] # +1 for indexing
703-
for j in range(x - weight_list[i] - 1): # +1 for indexing
704+
temp_list = [-x - j for j in range(self._r - x + 1)] # +1 for indexing
705+
for j in range(x - weight_list[i] - 1): # +1 for indexing
704706
temp_list.append(self._r - j)
705-
x = temp_list[-1] # This is the h+1 entry of the column
707+
x = temp_list[-1] # This is the h+1 entry of the column
706708
for j in range(weight_list[i]):
707709
temp_list.append(weight_list[i] - j)
708710

@@ -795,7 +797,7 @@ def _fill(self, shape):
795797
[[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, -5, 2], [-5, 3, -5, 3, -4, 3], [-4, 4, -4, 4, -3, 4], [-3, 5, -3, 5, -2, 5]]
796798
"""
797799
# Add zeros until the shape has length s
798-
shape_list = list(shape) # Make sure we have a list
800+
shape_list = list(shape) # Make sure we have a list
799801
while len(shape_list) != self._r:
800802
shape_list.append(0)
801803

@@ -892,39 +894,39 @@ def _fill(self, weight):
892894
[[1, 1, 1, 1, 1, 5, 1], [2, 2, 2, 2, 2, 6, 2], [3, 3, 9, 7, 9, 7, 3], [4, 4, 10, 8, 10, 8, 4], [5, 5, 11, 9, 11, 9, 5], [6, 6, 12, 10, 12, 10, 6], [7, 7, -12, 11, -12, 11, 7], [8, 8, -11, 12, -11, 12, 8], [9, 9, -10, -12, -10, -12, -8], [10, 10, -9, -11, -9, -11, -7], [-12, 11, -8, -10, -8, -10, -6], [-11, 12, -7, -9, -7, -9, -5]]
893895
"""
894896
# Add zeros until the shape has length s
895-
weight_list = list(weight) # Make sure we have a list
897+
weight_list = list(weight) # Make sure we have a list
896898
while len(weight_list) != self._s:
897899
weight_list.append(0)
898900

899901
tableau = []
900902
i = 0
901903
# Step 0 - Fill first columns of height r
902904
while i < self._s and weight_list[i] == self._r:
903-
tableau.append( [self._r - j for j in range(self._r)] )
905+
tableau.append([self._r - j for j in range(self._r)])
904906
i += 1
905907

906908
# Step 1 - Add the alternating columns until we hit an odd number of columns
907909
c = -1
908910
while i < self._s:
909911
# If it is an odd number of columns
910-
if i == self._s - 1 or weight_list[i] != weight_list[i+1]:
912+
if i == self._s - 1 or weight_list[i] != weight_list[i + 1]:
911913
c = weight_list[i]
912914
i += 1
913915
break
914916
temp_list = [-(weight_list[i] + j + 1) for j in range(self._r - weight_list[i])]
915917
for j in range(weight_list[i]):
916918
temp_list.append(weight_list[i] - j)
917919
tableau.append(temp_list)
918-
tableau.append( [self._r - j for j in range(self._r)] )
920+
tableau.append([self._r - j for j in range(self._r)])
919921
i += 2
920922

921923
# Step 2 - Add the x dependent columns
922924
x = c + 1
923925
while i < self._s:
924-
temp_list = [-x - j for j in range(self._r - x + 1)] # +1 for indexing
925-
for j in range(x - weight_list[i] - 1): # +1 for indexing
926+
temp_list = [-x - j for j in range(self._r - x + 1)] # +1 for indexing
927+
for j in range(x - weight_list[i] - 1): # +1 for indexing
926928
temp_list.append(self._r - j)
927-
x = temp_list[-1] # This is the h+1 entry of the column
929+
x = temp_list[-1] # This is the h+1 entry of the column
928930
for j in range(weight_list[i]):
929931
temp_list.append(weight_list[i] - j)
930932

@@ -990,7 +992,7 @@ def _build_module_generators(self):
990992

991993
tableau = []
992994
for i in range(self._s):
993-
tableau.append( [-n] + [self._r - j for j in range(self._r)] )
995+
tableau.append([-n] + [self._r - j for j in range(self._r)])
994996

995997
return (self.element_class(self, [self.letters(x) for x in flatten(tableau)]),)
996998

@@ -1016,8 +1018,8 @@ def _build_module_generators(self):
10161018
([[-2, 1], [-1, 2]], [[1, 1], [2, 2]])
10171019
"""
10181020
odd = int(self._s % 2)
1019-
shapes = [[int(x * 2 + odd) for x in sh] for sh
1020-
in vertical_dominoes_removed(self._r, self._s // 2)]
1021+
shapes = ([int(x * 2 + odd) for x in sh]
1022+
for sh in vertical_dominoes_removed(self._r, self._s // 2))
10211023
return tuple(self._fill(sh) for sh in shapes)
10221024

10231025
def from_kirillov_reshetikhin_crystal(self, krc):
@@ -1438,9 +1440,9 @@ def left_split(self):
14381440
if P._s == 1:
14391441
raise ValueError("cannot split a single column")
14401442
from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import \
1441-
TensorProductOfKirillovReshetikhinTableaux
1443+
TensorProductOfKirillovReshetikhinTableaux
14421444
r = P._r
1443-
TP = TensorProductOfKirillovReshetikhinTableaux(P._cartan_type, [[r, 1], [r, P._s-1]])
1445+
TP = TensorProductOfKirillovReshetikhinTableaux(P._cartan_type, [[r, 1], [r, P._s - 1]])
14441446
lf = TP.crystals[0](*(self[:r]))
14451447
rf = TP.crystals[1](*(self[r:]))
14461448
return TP(lf, rf)
@@ -1635,9 +1637,9 @@ def left_split(self):
16351637
if P._s == 1:
16361638
raise ValueError("cannot split a single column")
16371639
from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import \
1638-
TensorProductOfKirillovReshetikhinTableaux
1640+
TensorProductOfKirillovReshetikhinTableaux
16391641
h = P._cartan_type.classical().rank()
1640-
TP = TensorProductOfKirillovReshetikhinTableaux(P._cartan_type, [[P._r, 1], [P._r, P._s-1]])
1642+
TP = TensorProductOfKirillovReshetikhinTableaux(P._cartan_type, [[P._r, 1], [P._r, P._s - 1]])
16411643
lf = TP.crystals[0](*(self[:h]))
16421644
rf = TP.crystals[1](*(self[h:]))
16431645
return TP(lf, rf)

0 commit comments

Comments
 (0)