diff --git a/src/sage/combinat/crystals/alcove_path.py b/src/sage/combinat/crystals/alcove_path.py index 27222de68c7..0395dfca198 100644 --- a/src/sage/combinat/crystals/alcove_path.py +++ b/src/sage/combinat/crystals/alcove_path.py @@ -250,7 +250,7 @@ def __classcall_private__(cls, starting_weight, cartan_type=None, sage: B1 is B2 True """ - if isinstance(cartan_type, bool): # new style signature, optional arguments leak over + if isinstance(cartan_type, bool): # new style signature, optional arguments leak over highest_weight_crystal = cartan_type elif isinstance(cartan_type, (list, tuple)): # old style signature # switch positional arguments @@ -270,9 +270,10 @@ def __classcall_private__(cls, starting_weight, cartan_type=None, P = R.weight_space(extended=extended) Lambda = P.basis() offset = R.index_set()[Integer(0)] - starting_weight = P.sum(starting_weight[j-offset]*Lambda[j] for j in R.index_set()) + starting_weight = P.sum(starting_weight[j - offset] * Lambda[j] + for j in R.index_set()) - #set defaults + # set defaults if highest_weight_crystal is None: highest_weight_crystal = True @@ -334,9 +335,9 @@ def __init__(self, starting_weight, highest_weight_crystal): self._R = RootsWithHeight(starting_weight) self._finite_cartan_type = False - self.module_generators = ( self.element_class(self, ()), ) + self.module_generators = (self.element_class(self, ()),) - def _repr_(self): + def _repr_(self) -> str: """ Return a string representation of ``self``. @@ -367,7 +368,7 @@ def _element_constructor_(self, data): return self.element_class(self, data) elif isinstance(data, list): lambda_chain = self._R.lambda_chain() - #data starts indexing at 0 + # data starts indexing at 0 return self.element_class(self, tuple(sorted([lambda_chain[i] for i in data]))) def vertices(self): @@ -393,10 +394,10 @@ def vertices(self): EXAMPLES:: - sage: C = crystals.AlcovePaths(['C',2],[1,0]) + sage: C = crystals.AlcovePaths(['C', 2], [1, 0]) sage: C.vertices() [[], [0], [0, 1], [0, 1, 2]] - sage: C = crystals.AlcovePaths(['C',2,1],[2,1],False) + sage: C = crystals.AlcovePaths(['C', 2, 1], [2, 1], False) sage: len(C.vertices()) 80 @@ -420,12 +421,12 @@ def vertices(self): # lst contains ordered pairs (w,l) l= list of positions that get # you to the word, it needs to be refreshed - #initialization + # initialization lst = [] for i in range(len_lambda_chain): associated_reflection = lambda_chain[i].root.associated_reflection() if len(associated_reflection) == 1: - lst.append( (prod([ s[j] for j in associated_reflection ]), [i]) ) + lst.append((prod([s[j] for j in associated_reflection]), [i])) l = copy(lst) @@ -433,18 +434,18 @@ def vertices(self): lst2 = [] for x in lst: suc = getattr(x[0], successors)() - for j in range(x[1][-1]+1, len_lambda_chain): + for j in range(x[1][-1] + 1, len_lambda_chain): temp = x[0] * prod( - [ s[k] for k in lambda_chain[j].root.associated_reflection() ]) + [s[k] for k in lambda_chain[j].root.associated_reflection()]) if temp in suc: - lst2.append((temp,x[1]+[j])) - l.append((temp,x[1]+[j])) - if lst2 == []: + lst2.append((temp, x[1] + [j])) + l.append((temp, x[1] + [j])) + if not lst2: break else: lst = lst2 - return [ [] ] + [i[1] for i in l] + return [[]] + [i[1] for i in l] class CrystalOfAlcovePathsElement(ElementWrapper): @@ -612,8 +613,7 @@ def phi(self, i): raise NotImplementedError # I think the M below should still work in this case - M = Integer(m)/2 - Integer(1)/2 - return M + return Integer(m) / 2 - Integer(1) / 2 def epsilon(self, i): r""" @@ -627,7 +627,7 @@ def epsilon(self, i): sage: [c.epsilon(2) for c in C] [0, 0, 1, 2, 1, 1, 0, 0] """ - #crude but functional + # crude but functional j = 0 temp = self temp = temp.e(i) @@ -677,24 +677,21 @@ def weight(self): weight = -self.parent().weight for i in self.value[::-1]: root = root_space(i.root) - weight = -i.height*root + weight.reflection(root) + weight = -i.height * root + weight.reflection(root) WLR = self.parent().weight_lattice_realization() if self.cartan_type().is_affine() and self.parent()._highest_weight_crystal: # We assume that WLR is the (extended) weight lattice - wt = WLR._from_dict({i: Integer(c) for i,c in -weight}, + wt = WLR._from_dict({i: Integer(c) for i, c in -weight}, remove_zeros=False) return wt La = WLR.fundamental_weights() - wt = WLR.sum(Integer(c) * La[i] for i,c in -weight) + wt = WLR.sum(Integer(c) * La[i] for i, c in -weight) if self.cartan_type().is_affine(): assert not self.parent()._highest_weight_crystal wt -= La[0] * wt.level() return wt - #def __repr__(self): - #return str(self.integer_sequence()) - def plot(self): r""" Return a plot ``self``. @@ -716,7 +713,7 @@ def plot(self): for i in integer_sequence: foldings[i] = True affine_ambient_space = RootSystem(ct.affine()).ambient_space() - return affine_ambient_space.plot() + affine_ambient_space.plot_alcove_walk( word, foldings=foldings, labels=False) + return affine_ambient_space.plot() + affine_ambient_space.plot_alcove_walk(word, foldings=foldings, labels=False) def _richcmp_(self, other, op): r""" @@ -855,11 +852,11 @@ def _folding_data(self, i): for k in range(int(c1), int(c2)): - x = R( sign_Beta * Beta , k) + x = R(sign_Beta * Beta, k) if ( - ( j < len(J) - 1 and J[j] < x <= J[j+1] ) or - ( j == len(J) - 1 and J[j] < x) + (j < len(J) - 1 and J[j] < x <= J[j + 1]) or + (j == len(J) - 1 and J[j] < x) ): signs[x] = sign_Beta @@ -905,19 +902,20 @@ def e(self, i): KR_test = finite_cartan_type and i == 0 and m_index < len(gi) - 1 KR_test = KR_test and M >= 1 - ###################################################################### + ################################################################### # NOTE: # In the KR_case we want to insure that positions[m_index] is in J # If m_index > 0 then it's always true # If m_index == 0 then M >=1 guarantees this - ###################################################################### + ################################################################### - if ( (not finite_cartan_type or i != 0) and m_index < len(gi)-1 # alpha_i is a simple root - ) or KR_test: + if ((not finite_cartan_type or i != 0) and m_index < len(gi) - 1) or KR_test: + # first condition above means that alpha_i is a simple root J.remove(positions[m_index]) - if m_index+1 < len(positions): # if m_index+1 != 'infinity' - # i.e. positions[m_index+1] makes sense + if m_index + 1 < len(positions): + # if m_index+1 != 'infinity' + # i.e. positions[m_index+1] makes sense J.append(positions[m_index + 1]) return_value = Parent(tuple(sorted(J))) @@ -981,13 +979,15 @@ def _gi(self, i): if not positions: return (positions, [signs['infinity']]) - gi = [ signs[ positions[0] ] ] - for j in range(1,len(positions)): + gi = [signs[positions[0]]] + for j in range(1, len(positions)): gi.append( - gi[j-1] + - signs[positions[j-1]]*self._eps(positions[j-1]) + signs[positions[j]] ) - gi.append( gi[-1] + - signs[positions[-1]]*self._eps(positions[-1]) + signs['infinity'] ) + gi[j-1] + + signs[positions[j-1]] * self._eps(positions[j-1]) + + signs[positions[j]]) + gi.append(gi[-1] + + signs[positions[-1]] * self._eps(positions[-1]) + + signs['infinity']) return (positions, gi) @@ -1040,12 +1040,13 @@ def f(self, i): # # otherwise if m_index - 1 > 0 then (C2) is enough - if ( (not finite_cartan_type or i != 0) and M > 0 # alpha_i is a simple root - ) or KR_test :# KR case + if ((not finite_cartan_type or i != 0) and M > 0) or KR_test: + # first condition above means that alpha_i is a simple root - J.append(positions[m_index-1]) - if m_index < len(positions): # if m_index != 'infinity' - # thus positions[m_index] makes sense + J.append(positions[m_index - 1]) + if m_index < len(positions): + # if m_index != 'infinity' + # thus positions[m_index] makes sense J.remove(positions[m_index]) return_value = Parent(tuple(sorted(J))) @@ -1124,7 +1125,7 @@ def path(self): W = WeylGroup(self.parent()._R._cartan_type, prefix='s') s = W.simple_reflections() - #start at the identity + # start at the identity w = W.one() ret = [w] for i in self: @@ -1170,9 +1171,9 @@ def __init__(self, cartan_type): self._cartan_type = cartan_type Parent.__init__(self, category=HighestWeightCrystals().Infinite()) - self.module_generators = ( self.element_class(self, (), 0), ) + self.module_generators = (self.element_class(self, (), 0),) - def _repr_(self): + def _repr_(self) -> str: """ Return a string representation of ``self``. @@ -1231,7 +1232,7 @@ def e(self, i): A = CrystalOfAlcovePaths(self.parent()._cartan_type, [shift]*n) try: y = A(tuple([A._R(rt.root, rt.height - s(rt.root)) for rt in y.value])) - except ValueError: # Invalid height (and not admissible) + except ValueError: # Invalid height (and not admissible) break shift += 1 return type(self)(self.parent(), @@ -1271,7 +1272,7 @@ def f(self, i): shift = self._shift + 1 n = self.parent()._cartan_type.rank() A = CrystalOfAlcovePaths(self.parent()._cartan_type, [shift]*n) - y = A(tuple([A._R(rt, h + shift*s(rt)) for rt,h in self.value])).f(i) + y = A(tuple([A._R(rt, h + shift*s(rt)) for rt, h in self.value])).f(i) return type(self)(self.parent(), tuple([(rt.root, rt.height - shift*s(rt.root)) for rt in y.value]), @@ -1391,8 +1392,8 @@ def projection(self, k=None): return None s = lambda rt: int(sum(rt.associated_coroot().coefficients())) n = self.parent()._cartan_type.rank() - A = CrystalOfAlcovePaths(self.parent()._cartan_type, [k]*n) - return A(tuple([A._R(rt, h + k*s(rt)) for rt,h in self.value])) + A = CrystalOfAlcovePaths(self.parent()._cartan_type, [k] * n) + return A(tuple([A._R(rt, h + k*s(rt)) for rt, h in self.value])) class RootsWithHeight(UniqueRepresentation, Parent): @@ -1475,7 +1476,7 @@ def __init__(self, weight): sage: R = RootsWithHeight(['A',2],[3,2]) sage: TestSuite(R).run() """ - Parent.__init__(self, category=Sets() ) + Parent.__init__(self, category=Sets()) cartan_type = weight.parent().cartan_type() self._cartan_type = cartan_type @@ -1535,7 +1536,7 @@ def word(self): cartan_type = self._root_system.cartan_type() if not cartan_type.is_finite(): raise NotImplementedError - lambda_chain = [ x.root for x in self.lambda_chain() ] + lambda_chain = [x.root for x in self.lambda_chain()] coroot_lattice = RootSystem(cartan_type).coroot_lattice() cohighest_root = coroot_lattice.highest_root() @@ -1545,11 +1546,11 @@ def word(self): beta = lambda_chain[i] for j in reversed(range(i)): beta = beta.reflection(lambda_chain[j]) - #beta is now a simple root or the highest root + # beta is now a simple root or the highest root coroot = beta.associated_coroot() - support = coroot.support() # the path is in dual affine space - if len(support) == 1: # beta is a simple root + support = coroot.support() # the path is in dual affine space + if len(support) == 1: # beta is a simple root word.append(support[0]) elif coroot == -cohighest_root: word.append(0) @@ -1576,10 +1577,8 @@ def lambda_chain(self): if not self._root_lattice.cartan_type().is_finite(): raise ValueError("Cartan type {0} is not finite".format(self._root_lattice.cartan_type())) - l = [] - for i in self._root_lattice.positive_roots(): - for j in range(self._max_height(i)): - l.append(self(i,j)) + l = (self(i, j) for i in self._root_lattice.positive_roots() + for j in range(self._max_height(i))) return sorted(l) @@ -1611,7 +1610,7 @@ def _an_element_(self): sage: R._an_element_() (alpha[1], 0) """ - return self( self._root_lattice.from_vector(vector([1])), 0 ) + return self(self._root_lattice.from_vector(vector([1])), 0) class RootsWithHeightElement(Element): @@ -1659,9 +1658,10 @@ def __init__(self, parent, root, height): if not 0 <= height < max_height: raise ValueError("%d out of allowed range [%d,%d)" % (height, 0, max_height)) - v = [height/max_height] - v.extend( [ x/max_height for x in root.associated_coroot().to_vector() ] ) - #v.insert(0, height/max_height) + v = [height / max_height] + v.extend(x / max_height + for x in root.associated_coroot().to_vector()) + # v.insert(0, height/max_height) # the map from (root, height) --> _cmp_v is injective @@ -1744,8 +1744,8 @@ def _richcmp_(self, other, op): # I suspect that if you redefine this method to produce a # different (valid) `\lambda`-chain the rest of the # code should still work. - #todo: check if self and other have the same parent ? - #assert self.parent() is other.parent(), "elements have different parents" + # todo: check if self and other have the same parent ? + # assert self.parent() is other.parent(), "elements have different parents" return richcmp(self._cmp_v, other._cmp_v, op) @@ -1771,24 +1771,24 @@ def _test_some_specific_examples(clss=CrystalOfAlcovePaths): True """ # This appears in Lenart. - C = clss(['G',2],[0,1]) + C = clss(['G', 2], [0, 1]) G = C.digraph() GT = DiGraph({ - () : {(0) : 2 }, - (0) : {(0,8) : 1 }, - (0,1) : {(0,1,7) : 2 }, - (0,1,2) : {(0,1,2,9) : 1 }, - (0,1,2,3) : {(0,1,2,3,4) : 2 }, - (0,1,2,6) : {(0,1,2,3) : 1 }, - (0,1,2,9) : {(0,1,2,6) : 1 }, - (0,1,7) : {(0,1,2) : 2 }, - (0,1,7,9) : {(0,1,2,9) : 2 }, - (0,5) : {(0,1) : 1, (0,5,7) : 2 }, - (0,5,7) : {(0,5,7,9) : 1 }, - (0,5,7,9) : {(0,1,7,9) : 1 }, - (0,8) : {(0,5) : 1 } - }) + (): {(0): 2}, + (0): {(0, 8): 1}, + (0, 1): {(0, 1, 7): 2}, + (0, 1, 2): {(0, 1, 2, 9): 1}, + (0, 1, 2, 3): {(0, 1, 2, 3, 4): 2}, + (0, 1, 2, 6): {(0, 1, 2, 3): 1}, + (0, 1, 2, 9): {(0, 1, 2, 6): 1}, + (0, 1, 7): {(0, 1, 2): 2}, + (0, 1, 7, 9): {(0, 1, 2, 9): 2}, + (0, 5): {(0, 1): 1, (0, 5, 7): 2}, + (0, 5, 7): {(0, 5, 7, 9): 1}, + (0, 5, 7, 9): {(0, 1, 7, 9): 1}, + (0, 8): {(0, 5): 1} + }) if not G.is_isomorphic(GT): return False @@ -1798,23 +1798,23 @@ def _test_some_specific_examples(clss=CrystalOfAlcovePaths): # Some examples from Hong--Kang: # type C, ex. 8.3.5, pg. 189 - C = clss(['C',3],[0,0,1]) + C = clss(['C', 3], [0, 0, 1]) G = C.digraph() GT = DiGraph({ - ():{ (0): 3}, - (0):{ (0, 6): 2}, - (0, 1):{ (0, 1, 3): 3, (0, 1, 7): 1}, - (0, 1, 2):{ (0, 1, 2, 3): 3}, - (0, 1, 2, 3):{ (0, 1, 2, 3, 8): 2}, - (0, 1, 2, 3, 4):{ (0, 1, 2, 3, 4, 5): 3}, - (0, 1, 2, 3, 8):{ (0, 1, 2, 3, 4): 2}, - (0, 1, 3):{ (0, 1, 3, 7): 1}, - (0, 1, 3, 7):{ (0, 1, 2, 3): 1, (0, 1, 3, 7, 8): 2}, - (0, 1, 3, 7, 8):{ (0, 1, 2, 3, 8): 1}, - (0, 1, 7):{ (0, 1, 2): 1, (0, 1, 3, 7): 3}, - (0, 6):{ (0, 1): 2, (0, 6, 7): 1}, - (0, 6, 7):{ (0, 1, 7): 2} - }) + (): {(0): 3}, + (0): {(0, 6): 2}, + (0, 1): {(0, 1, 3): 3, (0, 1, 7): 1}, + (0, 1, 2): {(0, 1, 2, 3): 3}, + (0, 1, 2, 3): {(0, 1, 2, 3, 8): 2}, + (0, 1, 2, 3, 4): {(0, 1, 2, 3, 4, 5): 3}, + (0, 1, 2, 3, 8): {(0, 1, 2, 3, 4): 2}, + (0, 1, 3): {(0, 1, 3, 7): 1}, + (0, 1, 3, 7): {(0, 1, 2, 3): 1, (0, 1, 3, 7, 8): 2}, + (0, 1, 3, 7, 8): {(0, 1, 2, 3, 8): 1}, + (0, 1, 7): {(0, 1, 2): 1, (0, 1, 3, 7): 3}, + (0, 6): {(0, 1): 2, (0, 6, 7): 1}, + (0, 6, 7): {(0, 1, 7): 2} + }) if not G.is_isomorphic(GT): return False @@ -1822,68 +1822,68 @@ def _test_some_specific_examples(clss=CrystalOfAlcovePaths): print("C3 example passed.") # type B, fig. 8.1 pg. 172 - C = clss(['B',3],[2,0,0]) + C = clss(['B', 3], [2, 0, 0]) G = C.digraph() GT = DiGraph({ - ():{ (6): 1}, - (0):{ (0, 7): 2}, - (0, 1):{ (0, 1, 11): 3}, - (0, 1, 2):{ (0, 1, 2, 9): 2}, - (0, 1, 2, 3):{ (0, 1, 2, 3, 10): 1}, - (0, 1, 2, 3, 10):{ (0, 1, 2, 3, 4): 1}, - (0, 1, 2, 9):{ (0, 1, 2, 3): 2, (0, 1, 2, 9, 10): 1}, - (0, 1, 2, 9, 10):{ (0, 1, 2, 3, 10): 2}, - (0, 1, 5):{ (0, 1, 2): 3, (0, 1, 5, 9): 2}, - (0, 1, 5, 9):{ (0, 1, 2, 9): 3, (0, 1, 5, 9, 10): 1}, - (0, 1, 5, 9, 10):{ (0, 1, 2, 9, 10): 3}, - (0, 1, 8):{ (0, 1, 5): 3}, - (0, 1, 8, 9):{ (0, 1, 5, 9): 3, (0, 1, 8, 9, 10): 1}, - (0, 1, 8, 9, 10):{ (0, 1, 5, 9, 10): 3}, - (0, 1, 11):{ (0, 1, 8): 3}, - (0, 7):{ (0, 1): 2, (0, 7, 11): 3}, - (0, 7, 8):{ (0, 7, 8, 9): 2}, - (0, 7, 8, 9):{ (0, 1, 8, 9): 2}, - (0, 7, 8, 9, 10):{ (0, 1, 8, 9, 10): 2}, - (0, 7, 11):{ (0, 1, 11): 2, (0, 7, 8): 3}, - (6):{ (0): 1, (6, 7): 2}, - (6, 7):{ (0, 7): 1, (6, 7, 11): 3}, - (6, 7, 8):{ (0, 7, 8): 1, (6, 7, 8, 9): 2}, - (6, 7, 8, 9):{ (6, 7, 8, 9, 10): 1}, - (6, 7, 8, 9, 10):{ (0, 7, 8, 9, 10): 1}, - (6, 7, 11):{ (0, 7, 11): 1, (6, 7, 8): 3} - }) + (): {(6): 1}, + (0): {(0, 7): 2}, + (0, 1): {(0, 1, 11): 3}, + (0, 1, 2): {(0, 1, 2, 9): 2}, + (0, 1, 2, 3): {(0, 1, 2, 3, 10): 1}, + (0, 1, 2, 3, 10): {(0, 1, 2, 3, 4): 1}, + (0, 1, 2, 9): {(0, 1, 2, 3): 2, (0, 1, 2, 9, 10): 1}, + (0, 1, 2, 9, 10): {(0, 1, 2, 3, 10): 2}, + (0, 1, 5): {(0, 1, 2): 3, (0, 1, 5, 9): 2}, + (0, 1, 5, 9): {(0, 1, 2, 9): 3, (0, 1, 5, 9, 10): 1}, + (0, 1, 5, 9, 10): {(0, 1, 2, 9, 10): 3}, + (0, 1, 8): {(0, 1, 5): 3}, + (0, 1, 8, 9): {(0, 1, 5, 9): 3, (0, 1, 8, 9, 10): 1}, + (0, 1, 8, 9, 10): {(0, 1, 5, 9, 10): 3}, + (0, 1, 11): {(0, 1, 8): 3}, + (0, 7): {(0, 1): 2, (0, 7, 11): 3}, + (0, 7, 8): {(0, 7, 8, 9): 2}, + (0, 7, 8, 9): {(0, 1, 8, 9): 2}, + (0, 7, 8, 9, 10): {(0, 1, 8, 9, 10): 2}, + (0, 7, 11): {(0, 1, 11): 2, (0, 7, 8): 3}, + (6): {(0): 1, (6, 7): 2}, + (6, 7): {(0, 7): 1, (6, 7, 11): 3}, + (6, 7, 8): {(0, 7, 8): 1, (6, 7, 8, 9): 2}, + (6, 7, 8, 9): {(6, 7, 8, 9, 10): 1}, + (6, 7, 8, 9, 10): {(0, 7, 8, 9, 10): 1}, + (6, 7, 11): {(0, 7, 11): 1, (6, 7, 8): 3} + }) if not G.is_isomorphic(GT): return False else: print("B3 example 1 passed.") - C = clss(['B',3],[0,1,0]) + C = clss(['B', 3], [0, 1, 0]) G = C.digraph() GT = DiGraph({ - ():{ (0): 2}, - (0):{ (0, 1): 1, (0, 7): 3}, - (0, 1):{ (0, 1, 7): 3}, - (0, 1, 2):{ (0, 1, 2, 8): 2}, - (0, 1, 2, 3):{ (0, 1, 2, 3, 5): 1, (0, 1, 2, 3, 9): 3}, - (0, 1, 2, 3, 4):{ (0, 1, 2, 3, 4, 5): 1}, - (0, 1, 2, 3, 4, 5):{ (0, 1, 2, 3, 4, 5, 6): 2}, - (0, 1, 2, 3, 5):{ (0, 1, 2, 3, 5, 9): 3}, - (0, 1, 2, 3, 5, 9):{ (0, 1, 2, 3, 4, 5): 3}, - (0, 1, 2, 3, 9):{ (0, 1, 2, 3, 4): 3, (0, 1, 2, 3, 5, 9): 1}, - (0, 1, 2, 5):{ (0, 1, 2, 3, 5): 2}, - (0, 1, 2, 8):{ (0, 1, 2, 3): 2}, - (0, 1, 2, 8, 9):{ (0, 1, 2, 3, 9): 2}, - (0, 1, 7):{ (0, 1, 2): 3, (0, 1, 7, 8): 2}, - (0, 1, 7, 8):{ (0, 1, 7, 8, 9): 3}, - (0, 1, 7, 8, 9):{ (0, 1, 2, 8, 9): 3}, - (0, 2):{ (0, 1, 2): 1, (0, 2, 5): 2}, - (0, 2, 5):{ (0, 2, 5, 8): 1}, - (0, 2, 5, 8):{ (0, 1, 2, 5): 1}, - (0, 7):{ (0, 1, 7): 1, (0, 2): 3} - }) + (): {(0): 2}, + (0): {(0, 1): 1, (0, 7): 3}, + (0, 1): {(0, 1, 7): 3}, + (0, 1, 2): {(0, 1, 2, 8): 2}, + (0, 1, 2, 3): {(0, 1, 2, 3, 5): 1, (0, 1, 2, 3, 9): 3}, + (0, 1, 2, 3, 4): {(0, 1, 2, 3, 4, 5): 1}, + (0, 1, 2, 3, 4, 5): {(0, 1, 2, 3, 4, 5, 6): 2}, + (0, 1, 2, 3, 5): {(0, 1, 2, 3, 5, 9): 3}, + (0, 1, 2, 3, 5, 9): {(0, 1, 2, 3, 4, 5): 3}, + (0, 1, 2, 3, 9): {(0, 1, 2, 3, 4): 3, (0, 1, 2, 3, 5, 9): 1}, + (0, 1, 2, 5): {(0, 1, 2, 3, 5): 2}, + (0, 1, 2, 8): {(0, 1, 2, 3): 2}, + (0, 1, 2, 8, 9): {(0, 1, 2, 3, 9): 2}, + (0, 1, 7): {(0, 1, 2): 3, (0, 1, 7, 8): 2}, + (0, 1, 7, 8): {(0, 1, 7, 8, 9): 3}, + (0, 1, 7, 8, 9): {(0, 1, 2, 8, 9): 3}, + (0, 2): {(0, 1, 2): 1, (0, 2, 5): 2}, + (0, 2, 5): {(0, 2, 5, 8): 1}, + (0, 2, 5, 8): {(0, 1, 2, 5): 1}, + (0, 7): {(0, 1, 7): 1, (0, 2): 3} + }) if not G.is_isomorphic(GT): return False @@ -1919,9 +1919,9 @@ def compare_graphs(g1, g2, node1, node2): sage: compare_graphs(G1, G2, C( () ), G2.vertices(sort=True)[0]) True """ - for out_edge in g1.outgoing_edges( node1 ): + for out_edge in g1.outgoing_edges(node1): matched = False - for o2 in g2.outgoing_edges( node2 ): + for o2 in g2.outgoing_edges(node2): if o2[2] == out_edge[2]: if matched: print("ERROR: Two edges with the same label for ", out_edge, " exist.") @@ -1965,16 +1965,17 @@ def _test_against_tableaux(R, N, k, clss=CrystalOfAlcovePaths): T = CrystalOfTableaux(R, shape=shape) ct = len(T.list()) print(" T has ", ct, " nodes.") - #T.digraph().show(edge_labels=True) + # T.digraph().show(edge_labels=True) H = T.digraph() weight = T.module_generators[0].weight() - w = [ weight.scalar(RootSystem(R).ambient_space().simple_coroot(i)) for i in range(1,N+1) ] + w = [weight.scalar(RootSystem(R).ambient_space().simple_coroot(i)) + for i in range(1, N + 1)] print(" C weight ", w) - C = clss(R , w) + C = clss(R, w) cc = len(C.list()) - #C.digraph().show(edge_labels=True) + # C.digraph().show(edge_labels=True) G = C.digraph() print(" C has ", cc, " nodes.") if cc != ct: diff --git a/src/sage/combinat/crystals/bkk_crystals.py b/src/sage/combinat/crystals/bkk_crystals.py index b3658fd28a4..785f3fc7619 100644 --- a/src/sage/combinat/crystals/bkk_crystals.py +++ b/src/sage/combinat/crystals/bkk_crystals.py @@ -3,7 +3,7 @@ Benkart-Kang-Kashiwara crystals for the general-linear Lie superalgebra """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2017 Franco Saliola # 2017 Travis Scrimshaw # 2017 Anne Schilling @@ -12,8 +12,8 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.structure.parent import Parent from sage.categories.regular_supercrystals import RegularSuperCrystals @@ -60,7 +60,7 @@ def __classcall_private__(cls, ct, shape): """ ct = CartanType(ct) shape = _Partitions(shape) - if len(shape) > ct.m + 1 and shape[ct.m+1] > ct.n + 1: + if len(shape) > ct.m + 1 and shape[ct.m + 1] > ct.n + 1: raise ValueError("invalid hook shape") return super().__classcall__(cls, ct, shape) @@ -80,16 +80,14 @@ def __init__(self, ct, shape): C = CrystalOfBKKLetters(ct) tr = shape.conjugate() mg = [] - for i,col_len in enumerate(tr): - for j in range(col_len - m): - mg.append(C(i+1)) - for j in range(max(0, m - col_len), m): - mg.append(C(-j-1)) + for i, col_len in enumerate(tr, start=1): + mg.extend(C(i) for j in range(col_len - m)) + mg.extend(C(-j - 1) for j in range(max(0, m - col_len), m)) mg = list(reversed(mg)) Parent.__init__(self, category=RegularSuperCrystals()) self.module_generators = (self.element_class(self, mg),) - def _repr_(self): + def _repr_(self) -> str: """ Return a string representation of ``self``. diff --git a/src/sage/combinat/crystals/generalized_young_walls.py b/src/sage/combinat/crystals/generalized_young_walls.py index 12ab091f6cd..d88a200eaf0 100644 --- a/src/sage/combinat/crystals/generalized_young_walls.py +++ b/src/sage/combinat/crystals/generalized_young_walls.py @@ -20,7 +20,7 @@ - [KS2010]_ """ -#****************************************************************************** +# ***************************************************************************** # Copyright (C) 2013 # # Lucas David-Roesler (roesler at lvc dot edu) @@ -28,8 +28,8 @@ # Travis Scrimshaw (tscrim at ucdavis dot edu) # # Distributed under the terms of the GNU General Public License (GPL) -# http://www.gnu.org/licenses/ -#****************************************************************************** +# https://www.gnu.org/licenses/ +# ***************************************************************************** import re from copy import deepcopy @@ -69,7 +69,7 @@ def __init__(self, parent, data): sage: mg = Y.module_generators[0] sage: TestSuite(mg).run() """ - i = len(data)-1 + i = len(data) - 1 while i >= 0 and not data[i]: data.pop() i -= 1 @@ -118,7 +118,7 @@ def _repr_diagram(self): wall += '|' if row == []: wall += '|' - ret += wall.rjust(2*self.cols+1) + "\n" + ret += wall.rjust(2 * self.cols + 1) + "\n" return ret def _ascii_art_(self): @@ -175,9 +175,9 @@ def _unicode_art_(self): import unicodedata v = unicodedata.lookup('BOX DRAWINGS LIGHT VERTICAL') vl = unicodedata.lookup('BOX DRAWINGS LIGHT VERTICAL AND LEFT') - table = [[None]*(self.cols-len(row)) + row for row in reversed(self)] + table = [[None] * (self.cols - len(row)) + row for row in reversed(self)] ret = [] - for i,row in enumerate(ascii_art_table(table, use_unicode=True).splitlines()): + for i, row in enumerate(ascii_art_table(table, use_unicode=True).splitlines()): if row[-1] == " ": if i % 2 == 0: ret.append(row[:-1] + vl) @@ -228,19 +228,19 @@ def raw_signature(self, i): [['-', 3, 6], ['-', 1, 4], ['-', 6, 1]] """ sig = [] - rank = self.parent().cartan_type().rank() # n+1 + rank = self.parent().cartan_type().rank() # n+1 for row in range(self.rows): - if self.data[row] == [] and i == ( row % rank ): + if self.data[row] == [] and i == (row % rank): sig.append(['+', row, 0]) elif self.data[row] == []: continue - elif self.data[row][-1] == ( (i+1) % rank ): - sig.append(['+', row, len(self.data[row])+1]) + elif self.data[row][-1] == ((i + 1) % rank): + sig.append(['+', row, len(self.data[row]) + 1]) elif self.data[row][-1] == i: sig.append(['-', row, len(self.data[row])]) return sorted(sig, key=self._sig_sort) - def _sig_sort(self,a): + def _sig_sort(self, a): r""" Internal command used to appropriately sort the output from :meth:`raw_signature()`. @@ -256,7 +256,7 @@ def _sig_sort(self,a): sage: hw._sig_sort(['+',1,0]) (0, 1) """ - return (-a[2],a[1]) + return (-a[2], a[1]) def generate_signature(self, i): r""" @@ -273,20 +273,20 @@ def generate_signature(self, i): sig = [] rank = self.parent().cartan_type().classical().rank() for row in range(self.rows): - if self.data[row] == [] and i == ( row % (rank+1) ): + if self.data[row] == [] and i == (row % (rank + 1)): sig.append(['+', row, 0]) elif self.data[row] == []: continue - elif self.data[row][-1] == ( (i+1) % (rank+1) ): - sig.append(['+', row, len(self.data[row])+1]) + elif self.data[row][-1] == ((i + 1) % (rank + 1)): + sig.append(['+', row, len(self.data[row]) + 1]) elif self.data[row][-1] == i: sig.append(['-', row, len(self.data[row])]) sig = sorted(sig, key=self._sig_sort) - strsig = ''.join( x[0] for x in sig) + strsig = ''.join(x[0] for x in sig) reducedsig = strsig - while re.search(r"\+\s*-",reducedsig): - reducedsig = re.sub(r"\+\s*-", lambda match : ''.ljust(len(match.group(0))) , reducedsig) - return (sig,reducedsig) + while re.search(r"\+\s*-", reducedsig): + reducedsig = re.sub(r"\+\s*-", lambda match: ''.ljust(len(match.group(0))), reducedsig) + return (sig, reducedsig) def signature(self, i): r""" @@ -385,18 +385,19 @@ def number_of_parts(self): sage: y.number_of_parts() 8 """ - n = self.parent().cartan_type().rank()-1 + n = self.parent().cartan_type().rank() - 1 new = self.data[:] i = 0 while i < len(new): r = new[i] - if r == [] or r in new[i+1:]: + if not r or r in new[i + 1:]: new.pop(i) - elif r[0] == n and len(r) % (n+1) == 0: - for j in range(n+1): - temp = [k % (n+1) for k in range(j+len(r)/(n+1)-1,j-1,-1)] + elif r[0] == n and not len(r) % (n + 1): + for j in range(n + 1): + temp = [k % (n + 1) + for k in range(j + len(r) // (n + 1) - 1, j - 1, -1)] if temp not in new: - new.insert(i+1, temp) + new.insert(i + 1, temp) new.pop(i) else: i += 1 @@ -425,7 +426,7 @@ def sum_of_weighted_row_lengths(self): 15 """ n = self.parent().cartan_type().rank() - 1 - m = lambda i: len([1 for r in self.data if r and r[0] == (i-1) % (n+1)]) + m = lambda i: len([1 for r in self.data if r and r[0] == (i - 1) % (n + 1)]) for r in self.data: if r and r[0] == n: raise ValueError('Statistic only valid for generalized Young walls in Y_0') @@ -461,11 +462,11 @@ def e(self, i): newdata.append(list(self.data[r][:-1])) else: newdata.append(list(self.data[r])) - return self.__class__(self.parent(),newdata) + return self.__class__(self.parent(), newdata) else: return None - def f(self,i): + def f(self, i): r""" Return the application of the Kashiwara lowering operator `f_i` on ``self``. @@ -510,11 +511,12 @@ def latex_large(self): '\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n{{},{1,0,3,2},{2,1},{3,2,1,0,3,2},{},{},{2}} \n{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n' """ s = "" - if self.data == []: + if not self.data: s += "\\emptyset" else: s += "\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n" - s += "{" + ','.join("{" + ','.join( str(i) for i in r ) + "}" for r in self.data ) + "} \n" + s += "{" + ','.join("{" + ','.join(str(i) for i in r) + "}" + for r in self.data) + "} \n" s += "{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n" return s @@ -529,11 +531,12 @@ def _latex_(self): '\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n{{},{1,0,3,2},{2,1},{3,2,1,0,3,2},{},{},{2}} \n{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n' """ s = "" - if self.data == []: - s += "\\emptyset" + if not self.data: + s += "\\emptyset" else: s += "\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n" - s += "{" + ','.join("{" + ','.join( str(i) for i in r ) + "}" for r in self.data ) + "} \n" + s += "{" + ','.join("{" + ','.join(str(i) for i in r) + "}" + for r in self.data) + "} \n" s += "{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n" return s @@ -554,16 +557,13 @@ def weight(self, root_lattice=False): sage: x.weight(root_lattice=True) -2*alpha[0] - 3*alpha[1] - 5*alpha[2] - 3*alpha[3] """ - W = [] - E = self.cartan_type().root_system().weight_lattice(extended=True) L = self.cartan_type().root_system().root_lattice() alpha = L.simple_roots() - for r in self.data: - for i in r: - W.append(-1*alpha[i]) + W = sum(-1 * alpha[i] for r in self.data for i in r) if not root_lattice: - return E(sum(W)) - return L(sum(W)) + E = self.cartan_type().root_system().weight_lattice(extended=True) + return E(W) + return L(W) def epsilon(self, i): r""" @@ -587,7 +587,7 @@ def epsilon(self, i): self = self.e(i) if self is None: break - eps = eps+1 + eps += 1 return eps def Epsilon(self): @@ -601,7 +601,7 @@ def Epsilon(self): Lambda[0] + 3*Lambda[2] """ La = self.cartan_type().root_system().weight_lattice().fundamental_weights() - return sum(self.epsilon(i)*La[i] for i in self.index_set()) + return sum(self.epsilon(i) * La[i] for i in self.index_set()) def phi(self, i): r""" @@ -635,7 +635,7 @@ def Phi(self): 2*Lambda[0] + Lambda[1] - Lambda[2] + Lambda[3] """ La = self.cartan_type().root_system().weight_lattice(extended=True).fundamental_weights() - return sum(self.phi(i)*La[i] for i in self.index_set()) + return sum(self.phi(i) * La[i] for i in self.index_set()) def column(self, k): r""" @@ -651,15 +651,10 @@ def column(self, k): sage: hw.column(1) [] """ - C = [] - for row in self.data: - if k-1 < len(row): - C.append(row[k-1]) - else: - C.append(None) - return C + return [row[k - 1] if k - 1 < len(row) else None + for row in self.data] - def a(self,i,k): + def a(self, i, k): r""" Return the number `a_i(k)` of `i`-colored boxes in the ``k``-th column of ``self``. @@ -674,13 +669,11 @@ def a(self,i,k): sage: y.a(3,2) 0 """ - A = [] - for c in range(len(self.column(k))): - if self.column(k)[c] == i: - A.append(self.column(k)[c]) + A = [1 for c in range(len(self.column(k))) + if self.column(k)[c] == i] return len(A) - def in_highest_weight_crystal(self,La): + def in_highest_weight_crystal(self, La): r""" Return a boolean indicating if the generalized Young wall element is in the highest weight crystal cut out by the given highest weight @@ -718,14 +711,14 @@ def in_highest_weight_crystal(self,La): ac = self.parent().weight_lattice_realization().simple_coroots() n = self.cartan_type().classical().rank() index_set = self.index_set() - for k in range(1,self.cols+1): + for k in range(1, self.cols + 1): for j in index_set: - if self.a(j,k) - self.a( (j-1) % (n+1) ,k) <= 0: + if self.a(j, k) - self.a((j - 1) % (n + 1), k) <= 0: continue else: p_not_found = True for p in index_set: - if (j+k) % (n+1) == (p+1) % (n+1) and self.a(j,k) - self.a( (j-1) % (n+1) ,k) <= La.scalar(ac[p]): + if (j + k - p - 1) % (n + 1) == 0 and self.a(j, k) - self.a((j - 1) % (n + 1), k) <= La.scalar(ac[p]): p_not_found = False continue else: @@ -836,7 +829,7 @@ def __classcall_private__(cls, n, category=None): sage: Yinf is Yinf2 True """ - return super().__classcall__(cls,n,category) + return super().__classcall__(cls, n, category) def __init__(self, n, category): r""" @@ -845,15 +838,15 @@ def __init__(self, n, category): sage: Yinf = crystals.infinity.GeneralizedYoungWalls(3) sage: TestSuite(Yinf).run() """ - self._cartan_type = CartanType(['A',n,1]) + self._cartan_type = CartanType(['A', n, 1]) if category is None: category = (HighestWeightCrystals(), InfiniteEnumeratedSets()) Parent.__init__(self, category=category) - self.module_generators = (self.element_class(self,[]),) + self.module_generators = (self.element_class(self, []),) Element = GeneralizedYoungWall - def _element_constructor_(self,data): + def _element_constructor_(self, data): r""" Construct an element of ``self`` from ``data``. @@ -868,7 +861,7 @@ def _element_constructor_(self,data): sage: y [[], [1, 0], [2, 1]] """ - return self.element_class(self,data) + return self.element_class(self, data) def _repr_(self): r""" @@ -882,7 +875,7 @@ def _repr_(self): ######################## -## Highest weight GYW ## +# Highest weight GYW # ######################## class CrystalOfGeneralizedYoungWallsElement(GeneralizedYoungWall): @@ -890,7 +883,7 @@ class CrystalOfGeneralizedYoungWallsElement(GeneralizedYoungWall): Element of the highest weight crystal of generalized Young walls. """ - def e(self,i): + def e(self, i): r""" Compute the action of `e_i` restricted to the highest weight crystal. @@ -907,10 +900,10 @@ def e(self,i): if ret is None: return None if ret.in_highest_weight_crystal(self.parent().hw): - return self.__class__(self.parent(),ret.data) + return self.__class__(self.parent(), ret.data) return None - def f(self,i): + def f(self, i): r""" Compute the action of `f_i` restricted to the highest weight crystal. @@ -926,7 +919,7 @@ def f(self,i): """ ret = GeneralizedYoungWall.f(self, i) if ret.in_highest_weight_crystal(self.parent().hw): - return self.__class__(self.parent(),ret.data) + return self.__class__(self.parent(), ret.data) return None def weight(self): @@ -943,7 +936,7 @@ def weight(self): """ return self.parent().weight_lattice_realization()(self.parent().hw + GeneralizedYoungWall.weight(self)) - def phi(self,i): + def phi(self, i): r""" Return the value `\varepsilon_i(Y) + \langle h_i, \mathrm{wt}(Y)\rangle`, where `h_i` is the `i`-th simple @@ -1029,7 +1022,7 @@ def __classcall_private__(cls, n, La): sage: Y is Y1 True """ - La = RootSystem(['A',n,1]).weight_lattice(extended=True)(La) + La = RootSystem(['A', n, 1]).weight_lattice(extended=True)(La) return super().__classcall__(cls, n, La) def __init__(self, n, La): @@ -1043,8 +1036,8 @@ def __init__(self, n, La): sage: TestSuite(YLa).run(skip=["_test_enumerated_set_contains","_test_stembridge_local_axioms"]) # long time """ - InfinityCrystalOfGeneralizedYoungWalls.__init__( self, n, - category=(RegularCrystals(), HighestWeightCrystals(), InfiniteEnumeratedSets()) ) + InfinityCrystalOfGeneralizedYoungWalls.__init__(self, n, + category=(RegularCrystals(), HighestWeightCrystals(), InfiniteEnumeratedSets())) self.hw = La Element = CrystalOfGeneralizedYoungWallsElement diff --git a/src/sage/combinat/crystals/kirillov_reshetikhin.py b/src/sage/combinat/crystals/kirillov_reshetikhin.py index 411725aa0ea..3f3a2eaf0a7 100644 --- a/src/sage/combinat/crystals/kirillov_reshetikhin.py +++ b/src/sage/combinat/crystals/kirillov_reshetikhin.py @@ -330,7 +330,7 @@ def KirillovReshetikhinCrystal(cartan_type, r, s, model='KN'): return KirillovReshetikhinTableaux(cartan_type, r, s) if model in ['RC', 'RiggedConfigurations']: from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations - return RiggedConfigurations(cartan_type, [[r,s]]) + return RiggedConfigurations(cartan_type, [[r, s]]) if model == 'LSPaths': return KirillovReshetikhinCrystalFromLSPaths(cartan_type, r, s) @@ -378,7 +378,7 @@ def KashiwaraNakashimaTableaux(cartan_type, r, s): elif ct.type() == 'D': if r < ct.rank()-2: return KR_type_vertical(ct, r, s) - elif r in {ct.rank()-2,ct.rank()-1}: + elif r in {ct.rank()-2, ct.rank()-1}: return KR_type_spin(ct, r, s) else: raise ValueError("wrong range of parameters") @@ -396,9 +396,9 @@ def KashiwaraNakashimaTableaux(cartan_type, r, s): return KR_type_Cn(ct, r, s) else: raise ValueError("wrong range of parameters") - elif ct == CartanType(['E',6,1]) and r in [1,6,2]: + elif ct == CartanType(['E', 6, 1]) and r in [1, 6, 2]: return KR_type_E6(ct, r, s) - elif ct == CartanType(['E',7,1]) and r in [7]: + elif ct == CartanType(['E', 7, 1]) and r in [7]: return KR_type_E7(ct, r, s) else: raise NotImplementedError @@ -482,7 +482,7 @@ def _element_constructor_(self, *args, **options): elt = args[0] # Check to make sure it can be converted if elt.cartan_type() != self.cartan_type() \ - or elt.parent().r() != self._r or elt.parent().s() != self._s: + or elt.parent().r() != self._r or elt.parent().s() != self._s: raise ValueError("the Kirillov-Reshetikhin tableau must have the same Cartan type and shape") to_hw = elt.to_classical_highest_weight() @@ -758,9 +758,10 @@ def promotion(self): [[1, 3], [2, 4]] """ T = self.classical_crystal + ct = self._cartan_type[1] return CrystalDiagramAutomorphism(T, - lambda x: T(x.to_tableau().promotion(self._cartan_type[1])), - cache=False) + lambda x: T(x.to_tableau().promotion(ct)), + cache=False) @cached_method def promotion_inverse(self): @@ -782,9 +783,10 @@ def promotion_inverse(self): [[1, 2], [3, 3]] """ T = self.classical_crystal + ct = self._cartan_type[1] return CrystalDiagramAutomorphism(T, - lambda x: T(x.to_tableau().promotion_inverse(self._cartan_type[1])), - cache=False) + lambda x: T(x.to_tableau().promotion_inverse(ct)), + cache=False) def dynkin_diagram_automorphism(self, i): r""" @@ -973,7 +975,7 @@ def from_highest_weight_vector_to_pm_diagram(self, b): True """ n = self.cartan_type().rank() - 1 - inner = Partition([Integer(b.weight()[i]) for i in range(1,n+1)]) + inner = Partition([Integer(b.weight()[i]) for i in range(1, n+1)]) inter = Partition([len([i for i in r if i > 0]) for r in b.to_tableau()]) outer = b.to_tableau().shape() return PMDiagram([self.r(), self.s(), outer, inter, inner], from_shapes=True) @@ -1002,11 +1004,11 @@ def from_pm_diagram_to_highest_weight_vector(self, pm): ulist += list(range(1, h + 1)) for h in pm.heights_of_minus(): if ct_type == 'D': - ulist += list(range(1,rank+1)) + [rank-2-k for k in range(rank-1-h)] + ulist += list(range(1, rank+1)) + [rank-2-k for k in range(rank-1-h)] elif ct_type == 'B': - ulist += list(range(1,rank+1)) + [rank-k for k in range(rank+1-h)] + ulist += list(range(1, rank+1)) + [rank-k for k in range(rank+1-h)] else: - ulist += list(range(1,rank+1)) + [rank-1-k for k in range(rank-h)] + ulist += list(range(1, rank+1)) + [rank-1-k for k in range(rank-h)] for i in reversed(ulist): u = u.f(i) return u @@ -1079,7 +1081,7 @@ def classical_decomposition(self): (Finite dimensional highest weight crystal of type ['E', 6] and highest weight 2*Lambda[1],) """ La = self.cartan_type().classical().root_system().weight_lattice().fundamental_weights() - if self.r() in [1,6]: + if self.r() in [1, 6]: dw = [self.s() * La[self.r()]] elif self.r() == 2: dw = [k*La[2] for k in range(self.s()+1)] @@ -1103,7 +1105,7 @@ def dynkin_diagram_automorphism(self, i): sage: [K.dynkin_diagram_automorphism(i) for i in K.index_set()] [1, 6, 3, 5, 4, 2, 0] """ - aut = [1,6,3,5,4,2,0] + aut = [1, 6, 3, 5, 4, 2, 0] return aut[i] def affine_weight(self, b): @@ -1133,9 +1135,11 @@ def affine_weight(self, b): cl = self.cartan_type().classical() simple_roots = cl.root_system().ambient_space().simple_roots() index_set = cl.index_set() - weight = [Integer(b.weight().scalar( simple_roots[i] )) for i in index_set] + weight = [Integer(b.weight().scalar(simple_roots[i])) + for i in index_set] E6_coeffs = [1, 2, 2, 3, 2, 1] - return tuple([-sum(weight[i] * coeff for i,coeff in enumerate(E6_coeffs))] + weight) + return tuple([-sum(weight[i] * coeff + for i, coeff in enumerate(E6_coeffs))] + weight) @cached_method def hw_auxiliary(self): @@ -1241,11 +1245,11 @@ def promotion_on_highest_weight_vectors(self): dic = self.highest_weight_dict() dic_inv = self.highest_weight_dict_inv() dic_weight = {} - for (weight, i) in dic.values(): + for weight, i in dic.values(): dic_weight[weight] = dic_weight.get(weight, []) + [i] map_index = lambda i_list: max(i_list[1]) + min(i_list[1]) - i_list[0] - map_element = lambda x: ( self.automorphism_on_affine_weight(dic[x][0]), - map_index((dic[x][1], dic_weight[dic[x][0]])) ) + map_element = lambda x: (self.automorphism_on_affine_weight(dic[x][0]), + map_index((dic[x][1], dic_weight[dic[x][0]]))) return {x: dic_inv[map_element(x)] for x in dic} @cached_method @@ -1281,7 +1285,7 @@ def promotion(self): True """ T = self.classical_decomposition() - ind = [1,2,3,4,5] + ind = [1, 2, 3, 4, 5] return CrystalDiagramAutomorphism(T, self.promotion_on_highest_weight_vectors(), ind, automorphism=self.dynkin_diagram_automorphism) @@ -1300,7 +1304,7 @@ def promotion_inverse(self): True """ p = self.promotion() - #return lambda x : p(p(x)) + # return lambda x : p(p(x)) return p * p @@ -1353,7 +1357,7 @@ def ambient_crystal(self): sage: K.ambient_crystal() Kirillov-Reshetikhin crystal of type ['B', 4, 1]^* with (r,s)=(2,3) """ - return KashiwaraNakashimaTableaux(['A',2*self.cartan_type().classical().rank()+1,2], + return KashiwaraNakashimaTableaux(['A', 2*self.cartan_type().classical().rank()+1, 2], self.r(), self.s()) @cached_method @@ -1378,13 +1382,12 @@ def ambient_dict_pm_diagrams(self): [3, 1]: [[0, 0], [1, 1], [1]], [3, 3]: [[0, 0], [0, 0], [3]]} """ - ulist = [] s = self.s() r = self.r() m = s // 2 - for i in range(m+1): - for la in IntegerVectors(m-i, min_length=r, max_length=r): - ulist.append(PMDiagram([[j,j] for j in la]+[[s-2*m+2*i]])) + ulist = (PMDiagram([[j, j] for j in la]+[[s-2*m+2*i]]) + for i in range(m + 1) + for la in IntegerVectors(m-i, min_length=r, max_length=r)) return {x.inner_shape(): x for x in ulist} @cached_method @@ -1478,7 +1481,7 @@ class KR_type_CElement(KirillovReshetikhinGenericCrystalElement): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],1,2) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 1, 2) sage: type(K.module_generators[0]) """ @@ -1490,7 +1493,7 @@ def e0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],1,2) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 1, 2) sage: b = K(rows=[]) sage: b.e(0) # indirect doctest [[-1, -1]] @@ -1508,7 +1511,7 @@ def f0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],1,2) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 1, 2) sage: b = K(rows=[]) sage: b.f(0) # indirect doctest [[1, 1]] @@ -1618,7 +1621,7 @@ def module_generator(self): s = self.s() weight = s*Lambda[r] - s*Lambda[0] if r == self.cartan_type().rank() - 1: - weight += s*Lambda[r] # Special case for r == n + weight += s*Lambda[r] # Special case for r == n return [b for b in self.module_generators if b.weight() == weight][0] def classical_decomposition(self): @@ -1641,7 +1644,7 @@ def classical_decomposition(self): The crystal of tableaux of type ['B', 2] and shape(s) [[], [2], [2, 2]] """ return CrystalOfTableaux(['B', self.cartan_type().rank()-1], - shapes=horizontal_dominoes_removed(self.r(),self.s())) + shapes=horizontal_dominoes_removed(self.r(), self.s())) def ambient_crystal(self): r""" @@ -1681,13 +1684,12 @@ def ambient_dict_pm_diagrams(self): [2]: [[0, 0], [1, 1], [0]], [2, 2]: [[0, 0], [0, 0], [2]]} """ - ulist = [] s = self.s() r = self.r() m = s // 2 - for i in range(m+1): - for la in IntegerVectors(m-i, min_length=r, max_length=r): - ulist.append(PMDiagram([[j,j] for j in la]+[[s-2*m+2*i]])) + ulist = (PMDiagram([[j, j] for j in la] + [[s-2*m+2*i]]) + for i in range(m + 1) + for la in IntegerVectors(m-i, min_length=r, max_length=r)) return {x.inner_shape(): x for x in ulist} @cached_method @@ -1897,7 +1899,7 @@ def __init__(self, cartan_type, r, s): Kirillov-Reshetikhin crystal of type ['C', 3, 1]^* with (r,s)=(1,1) sage: TestSuite(K).run() """ - KirillovReshetikhinGenericCrystal.__init__(self, cartan_type, r ,s) + KirillovReshetikhinGenericCrystal.__init__(self, cartan_type, r, s) AffineCrystalFromClassical.__init__(self, cartan_type, self.classical_decomposition(), KirillovReshetikhinCrystals()) @@ -1921,7 +1923,7 @@ def classical_decomposition(self): The crystal of tableaux of type ['B', 3] and shape(s) [[], [1], [2], [1, 1], [3], [2, 1], [3, 1], [2, 2], [3, 2], [3, 3]] """ return CrystalOfTableaux(self.cartan_type().classical(), - shapes=partitions_in_box(self.r(),self.s())) + shapes=partitions_in_box(self.r(), self.s())) def ambient_crystal(self): r""" @@ -1938,7 +1940,7 @@ def ambient_crystal(self): """ # calling KR_type_C instead of KirillovReshetikhin(['C',n,1],r,s) has the advantage that # that this also works for r=n for A_{2n}^{(2)}. - return KR_type_C(['C', self.cartan_type().classical().rank(),1], self.r(), 2*self.s()) + return KR_type_C(['C', self.cartan_type().classical().rank(), 1], self.r(), 2*self.s()) @cached_method def highest_weight_dict(self): @@ -2017,10 +2019,10 @@ def to_ambient_crystal(self): ahwd = self.ambient_highest_weight_dict() pdict = {hwd[key]: ahwd[key] for key in hwd} classical = self.cartan_type().classical() - return self.crystal_morphism( pdict, codomain=self.ambient_crystal(), - index_set=classical.index_set(), - scaling_factors=self.similarity_factor(), - cartan_type=classical, check=False ) + return self.crystal_morphism(pdict, codomain=self.ambient_crystal(), + index_set=classical.index_set(), + scaling_factors=self.similarity_factor(), + cartan_type=classical, check=False) @cached_method def from_ambient_crystal(self): @@ -2045,9 +2047,9 @@ def from_ambient_crystal(self): hwd = self.highest_weight_dict() ahwd = self.ambient_highest_weight_dict() pdict_inv = {ahwd[key]: hwd[key] for key in hwd} - return AmbientRetractMap( self, self.ambient_crystal(), pdict_inv, - index_set=self.cartan_type().classical().index_set(), - similarity_factor_domain=self.similarity_factor() ) + return AmbientRetractMap(self, self.ambient_crystal(), pdict_inv, + index_set=self.cartan_type().classical().index_set(), + similarity_factor_domain=self.similarity_factor()) class KR_type_boxElement(KirillovReshetikhinGenericCrystalElement): @@ -2173,7 +2175,7 @@ def _element_constructor_(self, *args, **options): elt = args[0] # Check to make sure it can be converted if elt.cartan_type() != self.cartan_type() \ - or elt.parent().r() != self._r or elt.parent().s() != self._s: + or elt.parent().r() != self._r or elt.parent().s() != self._s: raise ValueError("the Kirillov-Reshetikhin tableau must have the same Cartan type and shape") to_hw = elt.to_classical_highest_weight() @@ -2227,7 +2229,7 @@ def ambient_crystal(self): sage: K.ambient_crystal() Kirillov-Reshetikhin crystal of type ['B', 3, 1]^* with (r,s)=(3,2) """ - return KashiwaraNakashimaTableaux(['A', 2*self.cartan_type().classical().rank()-1,2], + return KashiwaraNakashimaTableaux(['A', 2*self.cartan_type().classical().rank()-1, 2], self.r(), self.s()) @cached_method @@ -2281,7 +2283,7 @@ def similarity_factor(self): {1: 2, 2: 2, 3: 1} """ C = self.cartan_type().classical() - p = {i:2 for i in C.index_set()} + p = {i: 2 for i in C.index_set()} p[C.rank()] = 1 return p @@ -2301,10 +2303,10 @@ def to_ambient_crystal(self): ahwd = self.ambient_highest_weight_dict() pdict = {hwd[key]: ahwd[key] for key in hwd} classical = self.cartan_type().classical() - return self.crystal_morphism( pdict, codomain=self.ambient_crystal(), - index_set=classical.index_set(), - scaling_factors=self.similarity_factor(), - cartan_type=classical, check=False ) + return self.crystal_morphism(pdict, codomain=self.ambient_crystal(), + index_set=classical.index_set(), + scaling_factors=self.similarity_factor(), + cartan_type=classical, check=False) @cached_method def from_ambient_crystal(self): @@ -2327,9 +2329,9 @@ def from_ambient_crystal(self): hwd = self.highest_weight_dict() ahwd = self.ambient_highest_weight_dict() pdict_inv = {ahwd[key]: hwd[key] for key in hwd} - return AmbientRetractMap( self, self.ambient_crystal(), pdict_inv, - index_set=self.cartan_type().classical().index_set(), - similarity_factor_domain=self.similarity_factor() ) + return AmbientRetractMap(self, self.ambient_crystal(), pdict_inv, + index_set=self.cartan_type().classical().index_set(), + similarity_factor_domain=self.similarity_factor()) class KR_type_BnElement(KirillovReshetikhinGenericCrystalElement): @@ -2339,7 +2341,7 @@ class KR_type_BnElement(KirillovReshetikhinGenericCrystalElement): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['B',3,1],3,2) + sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 2) sage: type(K.module_generators[0]) """ @@ -2356,7 +2358,7 @@ def e0(self): sage: b.e(0) # indirect doctest [--+, []] """ - b = self.parent().to_ambient_crystal()(self).e_string([0,0]) + b = self.parent().to_ambient_crystal()(self).e_string([0, 0]) if b is None: return None return self.parent().from_ambient_crystal()(b) @@ -2368,12 +2370,11 @@ def f0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1) + sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 1) sage: b = K.module_generators[0] sage: b.f(0) # indirect doctest - """ - b = self.parent().to_ambient_crystal()(self).f_string([0,0]) + b = self.parent().to_ambient_crystal()(self).f_string([0, 0]) if b is None: return None return self.parent().from_ambient_crystal()(b) @@ -2385,7 +2386,7 @@ def epsilon0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1) + sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 1) sage: b = K.module_generators[0] sage: b.epsilon(0) # indirect doctest 1 @@ -2400,7 +2401,7 @@ def phi0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1) + sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 1) sage: b = K.module_generators[0] sage: b.phi(0) # indirect doctest 0 @@ -2444,7 +2445,8 @@ def classical_decomposition(self): sage: K.classical_decomposition() The crystal of tableaux of type ['C', 3] and shape(s) [[2, 2, 2]] """ - return CrystalOfTableaux(self.cartan_type().classical(), shape=[self.s()]*self.r() ) + return CrystalOfTableaux(self.cartan_type().classical(), + shape=[self.s()] * self.r()) def from_highest_weight_vector_to_pm_diagram(self, b): r""" @@ -2469,7 +2471,7 @@ def from_highest_weight_vector_to_pm_diagram(self, b): True """ n = self.cartan_type().rank()-1 - inner = Partition([Integer(b.weight()[i]) for i in range(1,n+1)]) + inner = Partition([Integer(b.weight()[i]) for i in range(1, n+1)]) inter = Partition([len([i for i in r if i > 0]) for r in b.to_tableau()]) outer = b.to_tableau().shape() return PMDiagram([self.r(), self.s(), outer, inter, inner], from_shapes=True) @@ -2496,7 +2498,7 @@ def from_pm_diagram_to_highest_weight_vector(self, pm): for h in pm.heights_of_addable_plus(): ulist += list(range(1, h + 1)) for h in pm.heights_of_minus(): - ulist += list(range(1,rank+1))+[rank-1-k for k in range(rank-h)] + ulist += list(range(1, rank+1))+[rank-1-k for k in range(rank-h)] for i in reversed(ulist): u = u.f(i) return u @@ -2509,7 +2511,7 @@ class KR_type_CnElement(KirillovReshetikhinGenericCrystalElement): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],3,2) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 2) sage: type(K.module_generators[0]) """ @@ -2523,7 +2525,7 @@ def e0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],3,2) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 2) sage: b = K.module_generators[0] sage: b.e(0) # indirect doctest [[1, 2], [2, 3], [3, -1]] @@ -2535,12 +2537,12 @@ def e0(self): [[3, -3], [-3, -2], [-1, -1]] """ n = self.parent().cartan_type().n - [b,l] = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) + b, l = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) - [l1,l2] = pm.pm_diagram[n-1] + l1, l2 = pm.pm_diagram[n-1] if l1 == 0: return None - pm.pm_diagram[n-1] = [l1-1,l2+1] + pm.pm_diagram[n-1] = [l1-1, l2+1] pm = PMDiagram(pm.pm_diagram) b = self.parent().from_pm_diagram_to_highest_weight_vector(pm) b = b.f_string(reversed(l)) @@ -2560,12 +2562,12 @@ def f0(self): sage: b.f(0) # indirect doctest """ n = self.parent().cartan_type().n - [b,l] = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) + b, l = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) - [l1,l2] = pm.pm_diagram[n-1] + l1, l2 = pm.pm_diagram[n-1] if l2 == 0: return None - pm.pm_diagram[n-1] = [l1+1,l2-1] + pm.pm_diagram[n-1] = [l1+1, l2-1] pm = PMDiagram(pm.pm_diagram) b = self.parent().from_pm_diagram_to_highest_weight_vector(pm) b = b.f_string(reversed(l)) @@ -2577,7 +2579,7 @@ def epsilon0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],3,1) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 1) sage: b = K.module_generators[0] sage: b.epsilon(0) # indirect doctest 1 @@ -2585,7 +2587,7 @@ def epsilon0(self): n = self.parent().cartan_type().n b = self.lift().to_highest_weight(index_set=list(range(2, n + 1)))[0] pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) - [l1,l2] = pm.pm_diagram[n-1] + l1, l2 = pm.pm_diagram[n-1] return l1 def phi0(self): @@ -2594,7 +2596,7 @@ def phi0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['C',3,1],3,1) + sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 1) sage: b = K.module_generators[0] sage: b.phi(0) # indirect doctest 0 @@ -2602,7 +2604,7 @@ def phi0(self): n = self.parent().cartan_type().n b = self.lift().to_highest_weight(index_set=list(range(2, n + 1)))[0] pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) - [l1,l2] = pm.pm_diagram[n-1] + l1, l2 = pm.pm_diagram[n-1] return l2 @@ -2644,7 +2646,7 @@ def _element_constructor_(self, *args, **options): elt = args[0] # Check to make sure it can be converted if elt.cartan_type() != self.cartan_type() \ - or elt.parent().r() != self._r or elt.parent().s() != self._s: + or elt.parent().r() != self._r or elt.parent().s() != self._s: raise ValueError("the Kirillov-Reshetikhin tableau must have" " the same Cartan type and shape") @@ -2679,7 +2681,8 @@ def classical_decomposition(self): s = s // 2 else: s = s / 2 - return CrystalOfTableaux(self.cartan_type().classical(), shape=[s]*self.r() ) + return CrystalOfTableaux(self.cartan_type().classical(), + shape=[s]*self.r()) def from_highest_weight_vector_to_pm_diagram(self, b): r""" @@ -2741,9 +2744,12 @@ def from_highest_weight_vector_to_pm_diagram(self, b): b = b[1] else: t = b.parent()(rows=[]) - inner = [Integer(2*b.weight()[i]+2*t.weight()[i]) for i in range(1,n+1)] - inter1 = Partition([len([i for i in r if i > 0]) for r in b.to_tableau()]) - inter = Partition([len([i for i in r if i >= 0]) for r in b.to_tableau()]) + inner = [Integer(2*b.weight()[i]+2*t.weight()[i]) + for i in range(1, n+1)] + inter1 = Partition([len([1 for i in r if i > 0]) + for r in b.to_tableau()]) + inter = Partition([len([1 for i in r if i >= 0]) + for r in b.to_tableau()]) if inter != inter1: inner[n-1] += 2 inner = Partition(inner) @@ -2784,7 +2790,7 @@ def from_pm_diagram_to_highest_weight_vector(self, pm): minus = pm.heights_of_minus() l = len([i for i in plus if i == rank-1]) a = (len(plus) + l) // 2 - ulist += sum(([i]*a for i in range(1,rank+1)),[]) + ulist += sum(([i]*a for i in range(1, rank+1)), []) a = (len(minus)-l) // 2 ulist += (list(range(1, rank + 1)) + [rank]) * a for i in reversed(ulist): @@ -2799,7 +2805,7 @@ class KR_type_Dn_twistedElement(KirillovReshetikhinGenericCrystalElement): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['D',4,2],3,2) + sage: K = crystals.KirillovReshetikhin(['D', 4, 2], 3, 2) sage: type(K.module_generators[0]) """ @@ -2813,16 +2819,16 @@ def e0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['D',4,2],3,3) + sage: K = crystals.KirillovReshetikhin(['D', 4, 2], 3, 3) sage: b = K.module_generators[0] sage: b.e(0) # indirect doctest [+++, [[2], [3], [0]]] """ n = self.parent().cartan_type().rank()-1 s = self.parent().s() - [b,l] = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) + b, l = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) - [l1,l2] = pm.pm_diagram[n-1] + l1, l2 = pm.pm_diagram[n-1] l3 = pm.pm_diagram[n-2][0] if l1+l2+l3 == s and l1 == 0: return None @@ -2855,9 +2861,9 @@ def f0(self): """ n = self.parent().cartan_type().rank()-1 s = self.parent().s() - [b,l] = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) + b, l = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) - [l1,l2] = pm.pm_diagram[n-1] + l1, l2 = pm.pm_diagram[n-1] l3 = pm.pm_diagram[n-2][0] if l1+l2+l3 == s and l2 == 0: return None @@ -2881,7 +2887,7 @@ def epsilon0(self): EXAMPLES:: - sage: K=crystals.KirillovReshetikhin(['D',4,2],3,1) + sage: K = crystals.KirillovReshetikhin(['D', 4, 2], 3, 1) sage: b = K.module_generators[0] sage: b.epsilon(0) # indirect doctest 1 @@ -2902,7 +2908,7 @@ def epsilon0(self): True """ n = self.parent().cartan_type().rank() - 1 - [b,l] = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) + b, l = self.lift().to_highest_weight(index_set=list(range(2, n + 1))) pm = self.parent().from_highest_weight_vector_to_pm_diagram(b) l1 = pm.pm_diagram[n-1][0] l4 = pm.pm_diagram[n][0] @@ -3031,7 +3037,7 @@ def _element_constructor_(self, *args, **options): elt = args[0] # Check to make sure it can be converted if elt.cartan_type() != self.cartan_type() \ - or elt.parent().r() != self._r or elt.parent().s() != self._s: + or elt.parent().r() != self._r or elt.parent().s() != self._s: raise ValueError("the Kirillov-Reshetikhin tableau must have the same Cartan type and shape") to_hw = elt.to_classical_highest_weight() @@ -3269,7 +3275,8 @@ def from_coordinates(self, coords): [[2, 2, 3, 0, -1]] """ C = self.classical_decomposition() - if not sum(coords): # Special empty element (i.e. the unique element of B(0)) + if not sum(coords): + # Special empty element (i.e. the unique element of B(0)) return self.element_class(self, C.module_generators[0]) l = C.letters @@ -3300,7 +3307,7 @@ def _element_constructor_(self, *args, **options): elt = args[0] # Check to make sure it can be converted if elt.cartan_type() != self.cartan_type() \ - or elt.parent().r() != self._r or elt.parent().s() != self._s: + or elt.parent().r() != self._r or elt.parent().s() != self._s: raise ValueError("the Kirillov-Reshetikhin tableau must have the same Cartan type and shape") to_hw = elt.to_classical_highest_weight() @@ -3330,10 +3337,10 @@ def coordinates(self): """ letters = self.parent().classical_decomposition().letters l = list(self.value) - return ( l.count(letters(1)), l.count(letters(2)), - 2*l.count(letters(3)) + l.count(letters(0)), - 2*l.count(letters(-3)) + l.count(letters(0)), - l.count(letters(-2)), l.count(letters(-1)) ) + return (l.count(letters(1)), l.count(letters(2)), + 2*l.count(letters(3)) + l.count(letters(0)), + 2*l.count(letters(-3)) + l.count(letters(0)), + l.count(letters(-2)), l.count(letters(-1))) @lazy_attribute def _A(self): @@ -3550,11 +3557,15 @@ def A7_decomposition(self): """ from sage.geometry.polyhedron.constructor import Polyhedron # variables are m_4, m_5, m_6, m_7 - P = Polyhedron(ieqs=[[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1],[0,-1,-1,0,1]], - eqns=[[-self._s,1,1,1,1]]) + P = Polyhedron(ieqs=[[0, 1, 0, 0, 0], + [0, 0, 1, 0, 0], + [0, 0, 0, 1, 0], + [0, 0, 0, 0, 1], + [0, -1, -1, 0, 1]], + eqns=[[-self._s, 1, 1, 1, 1]]) shapes = [Partition([6]*(p[3]-p[1]-p[0])+[4]*p[1]+[2]*p[2]).conjugate() for p in P.integral_points()] - return CrystalOfTableaux(['A',7], shapes=shapes) + return CrystalOfTableaux(['A', 7], shapes=shapes) @lazy_attribute def _highest_weight_to_A7_elements(self): @@ -3583,18 +3594,18 @@ def _highest_weight_to_A7_elements(self): d = {} A7 = self.A7_decomposition() for b in self: - if not b.is_highest_weight([1,3,4,5,6,7]): + if not b.is_highest_weight([1, 3, 4, 5, 6, 7]): continue - wt = [b.phi(i) for i in [7,6,5,4,3,1]] + wt = [b.phi(i) for i in [7, 6, 5, 4, 3, 1]] la = Partition([6]*(wt[4]+wt[5])+[4]*(wt[2]+wt[3])+[2]*(wt[0]+wt[1])).conjugate() - #mu = Partition(sum(([6-i]*m for i,m in enumerate(wt)), [])).conjugate() + # mu = Partition(sum(([6-i]*m for i,m in enumerate(wt)), [])).conjugate() x = A7.module_generator(la) for i in range(wt[0]): - x = x.f_string([2,3,4,5,6,7]) + x = x.f_string([2, 3, 4, 5, 6, 7]) for i in range(wt[2]): - x = x.f_string([4,5,6,7]) + x = x.f_string([4, 5, 6, 7]) for i in range(wt[4]): - x = x.f_string([6,7]) + x = x.f_string([6, 7]) d[b] = x return d @@ -3615,8 +3626,10 @@ def to_A7_crystal(self): Defn: ... """ d = self._highest_weight_to_A7_elements - return self.crystal_morphism(d, automorphism={1:6,3:5,4:4,5:3,6:2,7:1}, - index_set=[1,3,4,5,6,7], check=False) + return self.crystal_morphism(d, automorphism={1: 6, 3: 5, 4: 4, + 5: 3, 6: 2, 7: 1}, + index_set=[1, 3, 4, 5, 6, 7], + check=False) @cached_method def from_A7_crystal(self): @@ -3637,8 +3650,10 @@ def from_A7_crystal(self): A7 = self.A7_decomposition() d = self._highest_weight_to_A7_elements d_inv = {d[b]: b for b in d} - return A7.crystal_morphism(d_inv, automorphism={6:1,5:3,4:4,3:5,2:6,1:7}, - index_set=[1,2,3,4,5,6], check=False) + return A7.crystal_morphism(d_inv, automorphism={6: 1, 5: 3, 4: 4, + 3: 5, 2: 6, 1: 7}, + index_set=[1, 2, 3, 4, 5, 6], + check=False) class Element(KirillovReshetikhinGenericCrystalElement): def e0(self): @@ -3793,12 +3808,11 @@ def _repr_diagram(self): sage: pm = PMDiagram([[0,2], [0,0], [0]]) sage: print(pm._repr_diagram()) """ - t = [] ish = self.inner_shape() + [0] * self.n msh = self.intermediate_shape() + [0] * self.n osh = self.outer_shape() + [0] * self.n - for i in range(self.n): - t.append(['.']*ish[i]+['+']*(msh[i]-ish[i])+['-']*(osh[i]-msh[i])) + t = (['.'] * ish[i] + ['+'] * (msh[i]-ish[i]) + ['-'] * (osh[i]-msh[i]) + for i in range(self.n)) t = [i for i in t if i] return Tableau(t)._repr_diagram() if t else '' @@ -3837,10 +3851,8 @@ def inner_shape(self): sage: pm.inner_shape() [10, 7, 5, 3, 1] """ - t = [] ll = self._list - for i in range(self.n): - t.append(sum(ll[0:2*i+1])) + t = [sum(ll[0:2*i+1]) for i in range(self.n)] return Partition(list(reversed(t))) def outer_shape(self): @@ -3893,9 +3905,9 @@ def intermediate_shape(self): [1] """ p = self.inner_shape() - p = p + [0 for i in range(self.n)] + p = p + [0 for _ in range(self.n)] ll = list(reversed(self._list)) - p = [ p[i]+ll[2*i+1] for i in range(self.n) ] + p = [p[i] + ll[2*i+1] for i in range(self.n)] return Partition(p) def heights_of_minus(self): @@ -3933,7 +3945,7 @@ def heights_of_addable_plus(self): [1, 2, 3, 4] """ heights = [] - for i in range(1,self.n+1): + for i in range(1, self.n+1): heights += [i]*self.sigma().pm_diagram[i][0] return heights @@ -3953,11 +3965,11 @@ def sigma(self): return PMDiagram([list(reversed(a)) for a in pm]) -##################################################################################### +####################################################################### def partitions_in_box(r, s): """ - Returns all partitions in a box of width s and height r. + Return all partitions in a box of width s and height r. EXAMPLES:: @@ -3965,12 +3977,13 @@ def partitions_in_box(r, s): [[], [1], [2], [1, 1], [2, 1], [1, 1, 1], [2, 2], [2, 1, 1], [2, 2, 1], [2, 2, 2]] """ - return [x for n in range(r*s+1) for x in Partitions(n,max_part=s,max_length=r)] + return [x for n in range(r*s+1) + for x in Partitions(n, max_part=s, max_length=r)] def vertical_dominoes_removed(r, s): """ - Returns all partitions obtained from a rectangle of width s and height r by removing + Return all partitions obtained from a rectangle of width s and height r by removing vertical dominoes. EXAMPLES:: @@ -3982,12 +3995,12 @@ def vertical_dominoes_removed(r, s): sage: sage.combinat.crystals.kirillov_reshetikhin.vertical_dominoes_removed(4,2) [[], [1, 1], [1, 1, 1, 1], [2, 2], [2, 2, 1, 1], [2, 2, 2, 2]] """ - return [x.conjugate() for x in horizontal_dominoes_removed(s,r)] + return [x.conjugate() for x in horizontal_dominoes_removed(s, r)] def horizontal_dominoes_removed(r, s): """ - Returns all partitions obtained from a rectangle of width s and height r by removing + Return all partitions obtained from a rectangle of width s and height r by removing horizontal dominoes. EXAMPLES:: @@ -3998,11 +4011,11 @@ def horizontal_dominoes_removed(r, s): [[], [2], [2, 2], [2, 2, 2]] """ ulist = [list(x) + [0]*(r-x.length()) for x in partitions_in_box(r, s//2)] - two = lambda x : 2 * (x - s // 2) + s + two = lambda x: 2 * (x - s // 2) + s return [Partition([two(y) for y in x]) for x in ulist] ##################################################################### -## Morphisms +# Morphisms class AmbientRetractMap(Map): @@ -4030,7 +4043,7 @@ def __init__(self, base, ambient, pdict_inv, index_set, Map.__init__(self, Hom(ambient, base, SetsWithPartialMaps())) if similarity_factor_domain is None: - similarity_factor_domain = {i:1 for i in index_set} + similarity_factor_domain = {i: 1 for i in index_set} if automorphism is None: automorphism = lambda i: i @@ -4071,7 +4084,7 @@ def _call_(self, x): if c is not None: d = self(c).f(automorphism(i)) assert d is not None - #now we know that x is hw + # now we know that x is hw return d return self._pdict_inv[x] @@ -4150,7 +4163,7 @@ def _call_(self, x): cur = n break - if n is None: # We're at a I-highest weight element + if n is None: # We're at a I-highest weight element break if cur in self._cache: