Skip to content

Commit

Permalink
Trac #34287: modernize super in crystals and asymptotics
Browse files Browse the repository at this point in the history
using the short syntax `super()`

URL: https://trac.sagemath.org/34287
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Sep 25, 2022
2 parents d871894 + 3c729e3 commit d8b4ee8
Show file tree
Hide file tree
Showing 27 changed files with 102 additions and 161 deletions.
6 changes: 3 additions & 3 deletions src/sage/combinat/crystals/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __classcall__(cls, cartan_type, *args, **options):
True
"""
ct = CartanType(cartan_type)
return super(AffineCrystalFromClassical, cls).__classcall__(cls, ct, *args, **options)
return super().__classcall__(cls, ct, *args, **options)

def __init__(self, cartan_type, classical_crystal, category=None):
"""
Expand Down Expand Up @@ -397,7 +397,7 @@ def epsilon0(self):
sage: [x.epsilon0() for x in A.list()]
[1, 0, 0]
"""
return super(AffineCrystalFromClassicalElement, self).epsilon(0)
return super().epsilon(0)

def epsilon(self, i):
"""
Expand Down Expand Up @@ -436,7 +436,7 @@ def phi0(self):
sage: [x.phi0() for x in A.list()]
[0, 0, 1]
"""
return super(AffineCrystalFromClassicalElement, self).phi(0)
return super().phi(0)

def phi(self, i):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/crystals/affine_factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __classcall_private__(cls, w, n, x = None, k = None):
w0 = W.from_reduced_word(w[0].from_kbounded_to_reduced_word(k))
w1 = W.from_reduced_word(w[1].from_kbounded_to_reduced_word(k))
w = w0*(w1.inverse())
return super(AffineFactorizationCrystal, cls).__classcall__(cls, w, n, x)
return super().__classcall__(cls, w, n, x)

def __init__(self, w, n, x = None):
r"""
Expand Down
12 changes: 5 additions & 7 deletions src/sage/combinat/crystals/alcove_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,8 @@ def __classcall_private__(cls, starting_weight, cartan_type=None,
if not starting_weight.is_dominant():
raise ValueError("{0} is not a dominant weight".format(starting_weight))


return super(CrystalOfAlcovePaths, cls).__classcall__(cls,
starting_weight, highest_weight_crystal)

return super().__classcall__(cls, starting_weight,
highest_weight_crystal)

def __init__(self, starting_weight, highest_weight_crystal):
r"""
Expand Down Expand Up @@ -1153,7 +1151,7 @@ def __classcall_private__(cls, cartan_type):
True
"""
cartan_type = CartanType(cartan_type)
return super(InfinityCrystalOfAlcovePaths, cls).__classcall__(cls, cartan_type)
return super().__classcall__(cls, cartan_type)

def __init__(self, cartan_type):
"""
Expand Down Expand Up @@ -1394,6 +1392,7 @@ def projection(self, k=None):
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):
r"""
Data structure of the ordered pairs `(\beta,k)`,
Expand Down Expand Up @@ -1462,8 +1461,7 @@ def __classcall_private__(cls, starting_weight, cartan_type = None):
offset = R.index_set()[Integer(0)]
starting_weight = P.sum(starting_weight[j-offset]*Lambda[j] for j in R.index_set())

return super(RootsWithHeight, cls).__classcall__(cls, starting_weight)

return super().__classcall__(cls, starting_weight)

def __init__(self, weight):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/crystals/bkk_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __classcall_private__(cls, ct, shape):
shape = _Partitions(shape)
if len(shape) > ct.m + 1 and shape[ct.m+1] > ct.n + 1:
raise ValueError("invalid hook shape")
return super(CrystalOfBKKTableaux, cls).__classcall__(cls, ct, shape)
return super().__classcall__(cls, ct, shape)

def __init__(self, ct, shape):
r"""
Expand Down Expand Up @@ -135,7 +135,7 @@ def genuine_highest_weight_vectors(self, index_set=None):
"""
if index_set is None or index_set == self.index_set():
return self.module_generators
return super(CrystalOfBKKTableaux, self).genuine_highest_weight_vectors(index_set)
return super().genuine_highest_weight_vectors(index_set)

class Element(CrystalOfBKKTableauxElement):
pass
3 changes: 2 additions & 1 deletion src/sage/combinat/crystals/direct_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from sage.structure.element_wrapper import ElementWrapper
from sage.structure.element import get_coercion_model


class DirectSumOfCrystals(DisjointUnionEnumeratedSets):
r"""
Direct sum of crystals.
Expand Down Expand Up @@ -114,7 +115,7 @@ def __classcall_private__(cls, crystals, facade=True, keepkey=False, category=No
else:
ret.append(x)
category = Category.meet([Category.join(c.categories()) for c in ret])
return super(DirectSumOfCrystals, cls).__classcall__(cls,
return super().__classcall__(cls,
Family(ret), facade=facade, keepkey=keepkey, category=category)

def __init__(self, crystals, facade, keepkey, category, **options):
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/crystals/elementary_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def __classcall_private__(cls, cartan_type, weight=None):
weight = cartan_type
cartan_type = weight.parent().cartan_type()
cartan_type = CartanType(cartan_type)
return super(TCrystal, cls).__classcall__(cls, cartan_type, weight)
return super().__classcall__(cls, cartan_type, weight)

def __init__(self, cartan_type, weight):
r"""
Expand Down Expand Up @@ -514,7 +514,7 @@ def __classcall_private__(cls, cartan_type, weight=None, dual=False):
weight = cartan_type
cartan_type = weight.parent().cartan_type()
cartan_type = CartanType(cartan_type)
return super(RCrystal, cls).__classcall__(cls, cartan_type, weight, dual)
return super().__classcall__(cls, cartan_type, weight, dual)

def __init__(self, cartan_type, weight, dual):
r"""
Expand Down Expand Up @@ -789,7 +789,7 @@ def __classcall_private__(cls, cartan_type, i):
cartan_type = CartanType(cartan_type)
if i not in cartan_type.index_set():
raise ValueError('i must an element of the index set')
return super(ElementaryCrystal, cls).__classcall__(cls, cartan_type, i)
return super().__classcall__(cls, cartan_type, i)

def __init__(self, cartan_type, i):
r"""
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def __classcall_private__(cls, cartan_type, P=None):
P = cartan_type.root_system().ambient_space()
if P is None:
P = cartan_type.root_system().weight_lattice()
return super(ComponentCrystal, cls).__classcall__(cls, cartan_type, P)
return super().__classcall__(cls, cartan_type, P)

def __init__(self, cartan_type, P):
r"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/crystals/fast_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __classcall__(cls, cartan_type, shape, format = "string"):
if len(shape) > 2:
raise ValueError("The shape must have length <=2")
shape = shape + (0,)*(2-len(shape))
return super(FastCrystal, cls).__classcall__(cls, cartan_type, shape, format)
return super().__classcall__(cls, cartan_type, shape, format)

def __init__(self, ct, shape, format):
"""
Expand All @@ -127,7 +127,7 @@ def __init__(self, ct, shape, format):
sage: TestSuite(C).run()
"""
Parent.__init__(self, category = ClassicalCrystals())
# super(FastCrystal, self).__init__(category = FiniteEnumeratedSets())
# super().__init__(category = FiniteEnumeratedSets())
self._cartan_type = ct
if ct[1] != 2:
raise NotImplementedError
Expand Down Expand Up @@ -177,8 +177,8 @@ def __init__(self, ct, shape, format):
l2_str = "%d/2"%int(2*l2)
self.rename("The fast crystal for %s2 with shape [%s,%s]"%(ct[0],l1_str,l2_str))
self.module_generators = [self(0)]
# self._digraph = ClassicalCrystal.digraph(self)
self._digraph = super(FastCrystal, self).digraph()
# self._digraph = ClassicalCrystal.digraph(self)
self._digraph = super().digraph()
self._digraph_closure = self.digraph().transitive_closure()

def _type_a_init(self, l1, l2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def to_increasing_hecke_biword(self):
L[0] += [j+1]*len(self.value[-j-1])
return L


class DecreasingHeckeFactorizations(UniqueRepresentation, Parent):
"""
Set of decreasing factorizations in the 0-Hecke monoid.
Expand Down Expand Up @@ -358,7 +359,7 @@ def __classcall_private__(cls, w, factors, excess):
w = H.from_reduced_word(w.reduced_word())
if (not w.reduced_word()) and excess!=0:
raise ValueError("excess must be 0 for the empty word")
return super(DecreasingHeckeFactorizations, cls).__classcall__(cls, w, factors, excess)
return super().__classcall__(cls, w, factors, excess)

def __init__(self, w, factors, excess):
"""
Expand Down Expand Up @@ -520,7 +521,7 @@ def __classcall_private__(cls, w, factors, excess, shape=False):
w = H.from_reduced_word(w.reduced_word())
if (not w.reduced_word()) and excess!=0:
raise ValueError("excess must be 0 for the empty word")
return super(FullyCommutativeStableGrothendieckCrystal, cls).__classcall__(cls, w, factors, excess)
return super().__classcall__(cls, w, factors, excess)

def __init__(self, w, factors, excess):
"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/crystals/generalized_young_walls.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def __classcall_private__(cls, n, category=None):
sage: Yinf is Yinf2
True
"""
return super(InfinityCrystalOfGeneralizedYoungWalls,cls).__classcall__(cls,n,category)
return super().__classcall__(cls,n,category)

def __init__(self, n, category):
r"""
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def __classcall_private__(cls, n, La):
True
"""
La = RootSystem(['A',n,1]).weight_lattice(extended=True)(La)
return super(CrystalOfGeneralizedYoungWalls, cls).__classcall__(cls, n, La)
return super().__classcall__(cls, n, La)

def __init__(self, n, La):
r"""
Expand Down Expand Up @@ -1067,6 +1067,6 @@ def __iter__(self):
sage: next(x)
[0]
"""
for c in super(CrystalOfGeneralizedYoungWalls, self).__iter__():
for c in super().__iter__():
if c.in_highest_weight_crystal(self.hw):
yield c
3 changes: 2 additions & 1 deletion src/sage/combinat/crystals/induced_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from sage.structure.parent import Parent
from sage.structure.element_wrapper import ElementWrapper


class InducedCrystal(UniqueRepresentation, Parent):
r"""
A crystal induced from an injection.
Expand Down Expand Up @@ -120,7 +121,7 @@ def __classcall_private__(cls, X, phi, inverse=None, from_crystal=False):
if from_crystal:
return InducedFromCrystal(X, phi, inverse)

return super(InducedCrystal, cls).__classcall__(cls, X, phi, inverse)
return super().__classcall__(cls, X, phi, inverse)

def __init__(self, X, phi, inverse):
"""
Expand Down
9 changes: 5 additions & 4 deletions src/sage/combinat/crystals/infinity_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def __classcall_private__(cls, cartan_type):
return InfinityCrystalOfTableauxTypeD(cartan_type)
if cartan_type.type() == 'Q':
return DualInfinityQueerCrystalOfTableaux(cartan_type)
return super(InfinityCrystalOfTableaux, cls).__classcall__(cls, cartan_type)
return super().__classcall__(cls, cartan_type)

def __init__(self, cartan_type):
"""
Expand Down Expand Up @@ -288,7 +288,7 @@ def _coerce_map_from_(self, P):
or isinstance(P, InfinityCrystalOfNonSimplyLacedRC))):
from sage.combinat.rigged_configurations.bij_infinity import FromRCIsomorphism
return FromRCIsomorphism(Hom(P, self))
return super(InfinityCrystalOfTableaux, self)._coerce_map_from_(P)
return super()._coerce_map_from_(P)

class Element(InfinityCrystalOfTableauxElement):
r"""
Expand Down Expand Up @@ -605,7 +605,7 @@ def __classcall_private__(cls, cartan_type):
sage: B is B2
True
"""
return super(InfinityCrystalOfTableauxTypeD, cls).__classcall__(cls, CartanType(cartan_type))
return super().__classcall__(cls, CartanType(cartan_type))

@cached_method
def module_generator(self):
Expand Down Expand Up @@ -633,6 +633,7 @@ class Element(InfinityCrystalOfTableauxElementTypeD, InfinityCrystalOfTableaux.E
"""
pass


#########################################################
## Queer superalgebra

Expand All @@ -650,7 +651,7 @@ def __classcall_private__(cls, cartan_type):
True
"""
cartan_type = CartanType(cartan_type)
return super(DualInfinityQueerCrystalOfTableaux, cls).__classcall__(cls, cartan_type)
return super().__classcall__(cls, cartan_type)

def __init__(self, cartan_type):
"""
Expand Down
5 changes: 3 additions & 2 deletions src/sage/combinat/crystals/kac_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __classcall_private__(cls, cartan_type):
sage: S1 is S2
True
"""
return super(CrystalOfOddNegativeRoots, cls).__classcall__(cls, CartanType(cartan_type))
return super().__classcall__(cls, CartanType(cartan_type))

def __init__(self, cartan_type):
"""
Expand Down Expand Up @@ -430,6 +430,7 @@ def weight(self):
e = WLR.basis()
return WLR.sum(-e[i]+e[j] for (i,j) in self.value)


class CrystalOfKacModule(UniqueRepresentation, Parent):
r"""
Crystal of a Kac module.
Expand Down Expand Up @@ -530,7 +531,7 @@ def __classcall_private__(cls, cartan_type, la, mu):
cartan_type = CartanType(cartan_type)
la = _Partitions(la)
mu = _Partitions(mu)
return super(CrystalOfKacModule, cls).__classcall__(cls, cartan_type, la, mu)
return super().__classcall__(cls, cartan_type, la, mu)

def __init__(self, cartan_type, la, mu):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/crystals/kyoto_path_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def __classcall_private__(cls, crystals, weight, P=None):
enumerate(P.simple_coroots()) ) != level:
raise ValueError( "{} is not a level {} weight".format(weight, level) )

return super(KyotoPathModel, cls).__classcall__(cls, crystals, weight, P)
return super().__classcall__(cls, crystals, weight, P)

def __init__(self, crystals, weight, P):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/crystals/letters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ class ClassicalCrystalOfLetters(UniqueRepresentation, Parent):
C = CrystalOfNakajimaMonomials(cartan_type, la)
hw = C.highest_weight_vector()
self.module_generators = (self._element_constructor_(hw),)
self._list = [x for x in super(ClassicalCrystalOfLetters, self).__iter__()]
self._list = list(super(ClassicalCrystalOfLetters, self).__iter__())
elif cartan_type.type() == 'F':
from sage.combinat.crystals.monomial_crystals import CrystalOfNakajimaMonomials
from sage.combinat.root_system.root_system import RootSystem
la = RootSystem(cartan_type).weight_lattice().fundamental_weight(1)
C = CrystalOfNakajimaMonomials(cartan_type, la)
hw = C.highest_weight_vector()
self.module_generators = (self._element_constructor_(hw),)
self._list = [x for x in super(ClassicalCrystalOfLetters, self).__iter__()]
self._list = list(super(ClassicalCrystalOfLetters, self).__iter__())
else:
self.module_generators = (self._element_constructor_(1),)
if cartan_type.type() == 'G':
Expand Down Expand Up @@ -2522,7 +2522,7 @@ class CrystalOfBKKLetters(ClassicalCrystalOfLetters):
if dual is None:
dual = False
ct = CartanType(ct)
return super(CrystalOfBKKLetters, cls).__classcall__(cls, ct, dual)
return super().__classcall__(cls, ct, dual)

def __init__(self, ct, dual):
"""
Expand Down Expand Up @@ -2615,7 +2615,7 @@ class CrystalOfQueerLetters(ClassicalCrystalOfLetters):
The queer crystal of letters for q(3)
"""
ct = CartanType(ct)
return super(CrystalOfQueerLetters, cls).__classcall__(cls, ct)
return super().__classcall__(cls, ct)

def __init__(self, ct):
"""
Expand Down
5 changes: 3 additions & 2 deletions src/sage/combinat/crystals/littelmann_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ def __classcall_private__(cls, weight):
raise ValueError("The weight should be in the non-extended weight lattice!")
La = weight.parent().basis()
weight = weight - weight.level() * La[0] / La[0].level()
return super(CrystalOfLSPaths, cls).__classcall__(cls, weight, starting_weight_parent = weight.parent())
return super().__classcall__(cls, weight,
starting_weight_parent=weight.parent())

@cached_method
def maximal_vector(self):
Expand Down Expand Up @@ -1208,7 +1209,7 @@ def __classcall_private__(cls, cartan_type):
True
"""
cartan_type = CartanType(cartan_type)
return super(InfinityCrystalOfLSPaths, cls).__classcall__(cls, cartan_type)
return super().__classcall__(cls, cartan_type)

def __init__(self, cartan_type):
"""
Expand Down
Loading

0 comments on commit d8b4ee8

Please sign in to comment.