From 6a51349cb1bf1ef2b2b00a9815efe17e559c21db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 6 Aug 2022 13:49:06 +0200 Subject: [PATCH 1/4] modernize super in asymptotics and crystals --- src/sage/combinat/crystals/affine.py | 6 +- .../combinat/crystals/affine_factorization.py | 2 +- src/sage/combinat/crystals/alcove_path.py | 12 ++- src/sage/combinat/crystals/bkk_crystals.py | 4 +- src/sage/combinat/crystals/direct_sum.py | 3 +- .../combinat/crystals/elementary_crystals.py | 8 +- src/sage/combinat/crystals/fast_crystals.py | 10 +-- .../fully_commutative_stable_grothendieck.py | 5 +- .../crystals/generalized_young_walls.py | 6 +- .../combinat/crystals/induced_structure.py | 3 +- .../combinat/crystals/infinity_crystals.py | 9 +- src/sage/combinat/crystals/kac_modules.py | 5 +- .../combinat/crystals/kyoto_path_model.py | 2 +- src/sage/combinat/crystals/letters.pyx | 9 +- src/sage/combinat/crystals/littelmann_path.py | 5 +- .../combinat/crystals/monomial_crystals.py | 8 +- src/sage/combinat/crystals/pbw_crystal.py | 2 +- .../crystals/polyhedral_realization.py | 3 +- src/sage/combinat/crystals/subcrystal.py | 12 +-- src/sage/combinat/crystals/tensor_product.py | 5 +- .../crystals/tensor_product_element.pyx | 6 +- src/sage/combinat/crystals/virtual_crystal.py | 10 +-- src/sage/rings/asymptotic/asymptotic_ring.py | 83 +++---------------- ...otics_multivariate_generating_functions.py | 12 +-- .../asymptotic/growth_group_cartesian.py | 10 +-- src/sage/rings/asymptotic/misc.py | 22 ++--- src/sage/rings/asymptotic/term_monoid.py | 6 +- 27 files changed, 105 insertions(+), 163 deletions(-) diff --git a/src/sage/combinat/crystals/affine.py b/src/sage/combinat/crystals/affine.py index 65df64542b0..813492aad80 100644 --- a/src/sage/combinat/crystals/affine.py +++ b/src/sage/combinat/crystals/affine.py @@ -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): """ @@ -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): """ @@ -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""" diff --git a/src/sage/combinat/crystals/affine_factorization.py b/src/sage/combinat/crystals/affine_factorization.py index 1bc568aeb71..2499a05a5f9 100644 --- a/src/sage/combinat/crystals/affine_factorization.py +++ b/src/sage/combinat/crystals/affine_factorization.py @@ -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""" diff --git a/src/sage/combinat/crystals/alcove_path.py b/src/sage/combinat/crystals/alcove_path.py index e72e6a394e8..912e4797d02 100644 --- a/src/sage/combinat/crystals/alcove_path.py +++ b/src/sage/combinat/crystals/alcove_path.py @@ -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""" @@ -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): """ @@ -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)`, @@ -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""" diff --git a/src/sage/combinat/crystals/bkk_crystals.py b/src/sage/combinat/crystals/bkk_crystals.py index 622fbb9e350..15e795ca484 100644 --- a/src/sage/combinat/crystals/bkk_crystals.py +++ b/src/sage/combinat/crystals/bkk_crystals.py @@ -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""" @@ -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 diff --git a/src/sage/combinat/crystals/direct_sum.py b/src/sage/combinat/crystals/direct_sum.py index 84676264822..da2ce05bee2 100644 --- a/src/sage/combinat/crystals/direct_sum.py +++ b/src/sage/combinat/crystals/direct_sum.py @@ -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. @@ -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): diff --git a/src/sage/combinat/crystals/elementary_crystals.py b/src/sage/combinat/crystals/elementary_crystals.py index b3d01c09249..607206c52f6 100644 --- a/src/sage/combinat/crystals/elementary_crystals.py +++ b/src/sage/combinat/crystals/elementary_crystals.py @@ -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""" @@ -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""" @@ -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""" @@ -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""" diff --git a/src/sage/combinat/crystals/fast_crystals.py b/src/sage/combinat/crystals/fast_crystals.py index 2f964bb60de..9899f87122b 100644 --- a/src/sage/combinat/crystals/fast_crystals.py +++ b/src/sage/combinat/crystals/fast_crystals.py @@ -1,4 +1,4 @@ -r""" +sr""" Fast Rank Two Crystals """ # **************************************************************************** @@ -105,7 +105,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): """ @@ -116,7 +116,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 @@ -167,9 +167,9 @@ def __init__(self, ct, shape, format): self.rename("The fast crystal for %s2 with shape [%s,%s]"%(ct[0],l1_str,l2_str)) self.module_generators = [self(0)] # self._list = ClassicalCrystal.list(self) - self._list = super(FastCrystal, self).list() + self._list = super().list() # self._digraph = ClassicalCrystal.digraph(self) - self._digraph = super(FastCrystal, self).digraph() + self._digraph = super().digraph() self._digraph_closure = self.digraph().transitive_closure() def _type_a_init(self, l1, l2): diff --git a/src/sage/combinat/crystals/fully_commutative_stable_grothendieck.py b/src/sage/combinat/crystals/fully_commutative_stable_grothendieck.py index e2f9d09bd45..df9805e07b3 100644 --- a/src/sage/combinat/crystals/fully_commutative_stable_grothendieck.py +++ b/src/sage/combinat/crystals/fully_commutative_stable_grothendieck.py @@ -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. @@ -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): """ @@ -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): """ diff --git a/src/sage/combinat/crystals/generalized_young_walls.py b/src/sage/combinat/crystals/generalized_young_walls.py index 60c47154c8e..0d30991e00e 100644 --- a/src/sage/combinat/crystals/generalized_young_walls.py +++ b/src/sage/combinat/crystals/generalized_young_walls.py @@ -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""" @@ -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""" @@ -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 diff --git a/src/sage/combinat/crystals/induced_structure.py b/src/sage/combinat/crystals/induced_structure.py index 1e89220f3ea..a2265e8df71 100644 --- a/src/sage/combinat/crystals/induced_structure.py +++ b/src/sage/combinat/crystals/induced_structure.py @@ -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. @@ -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): """ diff --git a/src/sage/combinat/crystals/infinity_crystals.py b/src/sage/combinat/crystals/infinity_crystals.py index 0edf826c73e..7fa7e5f7a2d 100644 --- a/src/sage/combinat/crystals/infinity_crystals.py +++ b/src/sage/combinat/crystals/infinity_crystals.py @@ -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): """ @@ -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""" @@ -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): @@ -633,6 +633,7 @@ class Element(InfinityCrystalOfTableauxElementTypeD, InfinityCrystalOfTableaux.E """ pass + ######################################################### ## Queer superalgebra @@ -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): """ diff --git a/src/sage/combinat/crystals/kac_modules.py b/src/sage/combinat/crystals/kac_modules.py index f6244cd4158..90edd27d93d 100644 --- a/src/sage/combinat/crystals/kac_modules.py +++ b/src/sage/combinat/crystals/kac_modules.py @@ -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): """ @@ -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. @@ -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): """ diff --git a/src/sage/combinat/crystals/kyoto_path_model.py b/src/sage/combinat/crystals/kyoto_path_model.py index 12d3af264a6..6ee4d0e58a4 100644 --- a/src/sage/combinat/crystals/kyoto_path_model.py +++ b/src/sage/combinat/crystals/kyoto_path_model.py @@ -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): """ diff --git a/src/sage/combinat/crystals/letters.pyx b/src/sage/combinat/crystals/letters.pyx index 8a06939ce07..ccd57d461bf 100644 --- a/src/sage/combinat/crystals/letters.pyx +++ b/src/sage/combinat/crystals/letters.pyx @@ -116,6 +116,7 @@ def CrystalOfLetters(cartan_type, element_print_style=None, dual=None): else: raise NotImplementedError + class ClassicalCrystalOfLetters(UniqueRepresentation, Parent): r""" A generic class for classical crystals of letters. @@ -166,7 +167,7 @@ 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 = [x for x in super().__iter__()] elif cartan_type.type() == 'F': from sage.combinat.crystals.monomial_crystals import CrystalOfNakajimaMonomials from sage.combinat.root_system.root_system import RootSystem @@ -174,7 +175,7 @@ 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 = [x for x in super().__iter__()] else: self.module_generators = (self._element_constructor_(1),) if cartan_type.type() == 'G': @@ -2520,7 +2521,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): """ @@ -2613,7 +2614,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): """ diff --git a/src/sage/combinat/crystals/littelmann_path.py b/src/sage/combinat/crystals/littelmann_path.py index 9eb8ecd6dcd..2ddd6f3c461 100644 --- a/src/sage/combinat/crystals/littelmann_path.py +++ b/src/sage/combinat/crystals/littelmann_path.py @@ -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): @@ -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): """ diff --git a/src/sage/combinat/crystals/monomial_crystals.py b/src/sage/combinat/crystals/monomial_crystals.py index 43d71f16747..9accb0195e5 100644 --- a/src/sage/combinat/crystals/monomial_crystals.py +++ b/src/sage/combinat/crystals/monomial_crystals.py @@ -836,7 +836,7 @@ def __classcall_private__(cls, ct, c=None): cartan_type = CartanType(ct) n = len(cartan_type.index_set()) c = InfinityCrystalOfNakajimaMonomials._normalize_c(c, n) - M = super(InfinityCrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, c) + M = super().__classcall__(cls, cartan_type, c) M.set_variables('Y') return M @@ -1074,7 +1074,7 @@ def f(self, i): """ if self.phi(i) == 0: return None - return super(CrystalOfNakajimaMonomialsElement, self).f(i) + return super().f(i) def weight(self): r""" @@ -1197,7 +1197,7 @@ def __classcall_private__(cls, cartan_type, La=None, c=None): La = RootSystem(cartan_type).weight_lattice()(La) n = len(cartan_type.index_set()) c = InfinityCrystalOfNakajimaMonomials._normalize_c(c, n) - return super(CrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, La, c) + return super().__classcall__(cls, cartan_type, La, c) def __init__(self, ct, La, c): r""" @@ -1252,6 +1252,6 @@ def cardinality(self): """ if not self.cartan_type().is_finite(): return Infinity - return super(InfinityCrystalOfNakajimaMonomials, self).cardinality() + return super().cardinality() Element = CrystalOfNakajimaMonomialsElement diff --git a/src/sage/combinat/crystals/pbw_crystal.py b/src/sage/combinat/crystals/pbw_crystal.py index 1803b501f9e..4a313c8fa78 100644 --- a/src/sage/combinat/crystals/pbw_crystal.py +++ b/src/sage/combinat/crystals/pbw_crystal.py @@ -401,7 +401,7 @@ def __classcall__(cls, cartan_type): cartan_type = CartanType(cartan_type) if not cartan_type.is_finite(): raise NotImplementedError("only implemented for finite types") - return super(PBWCrystal, cls).__classcall__(cls, cartan_type) + return super().__classcall__(cls, cartan_type) def __init__(self, cartan_type): """ diff --git a/src/sage/combinat/crystals/polyhedral_realization.py b/src/sage/combinat/crystals/polyhedral_realization.py index 2860eec417c..a709284149f 100644 --- a/src/sage/combinat/crystals/polyhedral_realization.py +++ b/src/sage/combinat/crystals/polyhedral_realization.py @@ -25,6 +25,7 @@ from sage.combinat.crystals.elementary_crystals import ElementaryCrystal from sage.combinat.root_system.cartan_type import CartanType + class InfinityCrystalAsPolyhedralRealization(TensorProductOfCrystals): r""" The polyhedral realization of `B(\infty)`. @@ -156,7 +157,7 @@ def __classcall_private__(cls, cartan_type, seq=None): seq = tuple(seq) if set(seq) != set(cartan_type.index_set()): raise ValueError("the support of seq is not the index set") - return super(InfinityCrystalAsPolyhedralRealization, cls).__classcall__(cls, cartan_type, seq) + return super().__classcall__(cls, cartan_type, seq) def __init__(self, cartan_type, seq): """ diff --git a/src/sage/combinat/crystals/subcrystal.py b/src/sage/combinat/crystals/subcrystal.py index 9881a021e27..22e22453488 100644 --- a/src/sage/combinat/crystals/subcrystal.py +++ b/src/sage/combinat/crystals/subcrystal.py @@ -159,11 +159,11 @@ def __classcall_private__(cls, ambient, contained=None, generators=None, generators, cartan_type, index_set, category) # We need to give these as optional arguments so it unpickles correctly - return super(Subcrystal, cls).__classcall__(cls, ambient, contained, - tuple(generators), - cartan_type=cartan_type, - index_set=tuple(index_set), - category=category) + return super().__classcall__(cls, ambient, contained, + tuple(generators), + cartan_type=cartan_type, + index_set=tuple(index_set), + category=category) def __init__(self, ambient, contained, generators, cartan_type, index_set, category): """ @@ -291,7 +291,7 @@ def cardinality(self): if self in FiniteCrystals(): return Integer(len(self.list())) try: - card = super(Subcrystal, self).cardinality() + card = super().cardinality() except AttributeError: raise NotImplementedError("unknown cardinality") if card == infinity: diff --git a/src/sage/combinat/crystals/tensor_product.py b/src/sage/combinat/crystals/tensor_product.py index c15eac03795..18d80008ccb 100644 --- a/src/sage/combinat/crystals/tensor_product.py +++ b/src/sage/combinat/crystals/tensor_product.py @@ -689,6 +689,7 @@ class FullTensorProductOfQueerSuperCrystals(FullTensorProductOfCrystals, QueerSu class Element(TensorProductOfQueerSuperCrystalsElement): pass + ######################################################### ## Crystal of tableaux @@ -931,7 +932,7 @@ def __classcall_private__(cls, cartan_type, shapes = None, shape = None): raise ValueError("shapes should all be partitions or half-integer partitions") if spin_shapes == shapes: shapes = tuple(_Partitions(shape) if shape[n1-1] in NN else shape for shape in shapes) - return super(CrystalOfTableaux, cls).__classcall__(cls, cartan_type, shapes) + return super().__classcall__(cls, cartan_type, shapes) # Handle the construction of a crystals of spin tableaux # Caveat: this currently only supports all shapes being half @@ -979,7 +980,7 @@ def __init__(self, cartan_type, shapes): sage: T = crystals.Tableaux(['A',3], shape = [2,2]) sage: TestSuite(T).run() """ -# super(CrystalOfTableaux, self).__init__(category = FiniteEnumeratedSets()) +# super().__init__(category = FiniteEnumeratedSets()) Parent.__init__(self, category = ClassicalCrystals()) self.letters = CrystalOfLetters(cartan_type) self.shapes = shapes diff --git a/src/sage/combinat/crystals/tensor_product_element.pyx b/src/sage/combinat/crystals/tensor_product_element.pyx index b7f60016ecc..fad1ced578d 100644 --- a/src/sage/combinat/crystals/tensor_product_element.pyx +++ b/src/sage/combinat/crystals/tensor_product_element.pyx @@ -478,6 +478,7 @@ cdef class TensorProductOfCrystalsElement(ImmutableListWithParent): return self._set_index(-k, crystal) return None + cdef class TensorProductOfRegularCrystalsElement(TensorProductOfCrystalsElement): """ Element class for a tensor product of regular crystals. @@ -1651,6 +1652,7 @@ cdef class TensorProductOfQueerSuperCrystalsElement(TensorProductOfRegularCrysta x = x.f(i) return string_length + cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrystalsElement): def __init__(self, parent, list, row_lengths=[]): """ @@ -1673,7 +1675,7 @@ cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrysta row_lengths.append(len(row)) list = ret self._row_lengths = row_lengths - super(InfinityQueerCrystalOfTableauxElement, self).__init__(parent, list) + super().__init__(parent, list) def _repr_(self): r""" @@ -1768,7 +1770,7 @@ cdef class InfinityQueerCrystalOfTableauxElement(TensorProductOfQueerSuperCrysta [[4, 4, 4, 4, 4, 3, 2, 1], [3, 3, 3, 3], [2, 2, 1], [1]] sage: t.e(-1) """ - ret = super(InfinityQueerCrystalOfTableauxElement, self).e(i) + ret = super().e(i) if ret is None: return None ( ret)._row_lengths = self._row_lengths diff --git a/src/sage/combinat/crystals/virtual_crystal.py b/src/sage/combinat/crystals/virtual_crystal.py index a537a64bfb8..0283b4a9543 100644 --- a/src/sage/combinat/crystals/virtual_crystal.py +++ b/src/sage/combinat/crystals/virtual_crystal.py @@ -23,14 +23,13 @@ # # http://www.gnu.org/licenses/ #**************************************************************************** - - from sage.categories.crystals import Crystals from sage.categories.finite_crystals import FiniteCrystals from sage.combinat.root_system.cartan_type import CartanType from sage.combinat.crystals.subcrystal import Subcrystal from sage.sets.family import Family + class VirtualCrystal(Subcrystal): r""" A virtual crystal `V` of an ambient crystal `\widehat{B}` is a crystal @@ -195,9 +194,10 @@ def __classcall_private__(cls, ambient, virtualization, scaling_factors, if ambient in FiniteCrystals() or isinstance(contained, frozenset): category = category.Finite() - return super(Subcrystal, cls).__classcall__(cls, ambient, virtualization, scaling_factors, - contained, tuple(generators), cartan_type, - tuple(index_set), category) + return super().__classcall__(cls, ambient, virtualization, + scaling_factors, contained, + tuple(generators), cartan_type, + tuple(index_set), category) def __init__(self, ambient, virtualization, scaling_factors, contained, generators, cartan_type, index_set, category): diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py index ed8504ebc95..4c5deb5ce21 100644 --- a/src/sage/rings/asymptotic/asymptotic_ring.py +++ b/src/sage/rings/asymptotic/asymptotic_ring.py @@ -428,7 +428,6 @@ class NoConvergenceError(RuntimeError): A special :python:`RuntimeError` which is raised when an algorithm does not converge/stop. """ - pass class AsymptoticExpansion(CommutativeAlgebraElement): @@ -666,7 +665,7 @@ def __init__(self, parent, summands, simplify=True, convert=True): sage: 1 + (-1)^x + 2^x + (-2)^x 2^x + 2^x*(-1)^x + (-1)^x + 1 """ - super(AsymptoticExpansion, self).__init__(parent=parent) + super().__init__(parent=parent) from sage.data_structures.mutable_poset import MutablePoset if not isinstance(summands, MutablePoset): @@ -716,7 +715,6 @@ def summands(self): """ return self._summands_ - def __hash__(self): r""" A hash value for this element. @@ -736,7 +734,6 @@ def __hash__(self): """ return hash(str(self)) - def __bool__(self): r""" Return whether this asymptotic expansion is not identically zero. @@ -761,8 +758,6 @@ def __bool__(self): """ return bool(self._summands_) - - def __eq__(self, other): r""" Return whether this asymptotic expansion is equal to ``other``. @@ -805,7 +800,6 @@ def __eq__(self, other): except (TypeError, ValueError): return False - def __ne__(self, other): r""" Return whether this asymptotic expansion is not equal to ``other``. @@ -838,7 +832,6 @@ def __ne__(self, other): """ return not self == other - def has_same_summands(self, other): r""" Return whether this asymptotic expansion and ``other`` have the @@ -887,7 +880,6 @@ def has_same_summands(self, other): lambda self, other: self._has_same_summands_(other)) - def _has_same_summands_(self, other): r""" Return whether this :class:`AsymptoticExpansion` has the same @@ -961,7 +953,6 @@ def _simplify_(self): """ self._summands_.merge(reverse=True) - def _repr_(self, latex=False): r""" A representation string for this asymptotic expansion. @@ -996,7 +987,6 @@ def _repr_(self, latex=False): return '0' return s - def _latex_(self): r""" A LaTeX-representation string for this asymptotic expansion. @@ -1015,7 +1005,6 @@ def _latex_(self): """ return self._repr_(latex=True) - def show(self): r""" Pretty-print this asymptotic expansion. @@ -1162,7 +1151,6 @@ def _add_(self, other): return self.parent()(self.summands.union(other.summands), simplify=True, convert=False) - def _sub_(self, other): r""" Subtract ``other`` from this asymptotic expansion. @@ -1191,7 +1179,6 @@ def _sub_(self, other): """ return self + self.parent().coefficient_ring(-1)*other - def _mul_term_(self, term): r""" Helper method: multiply this asymptotic expansion by the @@ -1408,10 +1395,8 @@ def __invert__(self, precision=None): return result._mul_term_(imax_elem) - invert = __invert__ - def truncate(self, precision=None): r""" Truncate this asymptotic expansion. @@ -1704,7 +1689,7 @@ def __pow__(self, exponent, precision=None): except (TypeError, ValueError): pass else: - return super(AsymptoticExpansion, self).__pow__(exponent) + return super().__pow__(exponent) from sage.rings.rational_field import QQ try: @@ -1926,7 +1911,6 @@ def sqrt(self, precision=None): from sage.rings.rational_field import QQ return self.pow(QQ(1)/QQ(2), precision=precision) - def O(self): r""" Convert all terms in this asymptotic expansion to `O`-terms. @@ -1972,7 +1956,6 @@ def O(self): return sum(self.parent().create_summand('O', growth=element) for element in self.summands.maximal_elements()) - def log(self, base=None, precision=None, locals=None): r""" The logarithm of this asymptotic expansion. @@ -2106,7 +2089,6 @@ def log(self, base=None, precision=None, locals=None): return result - def is_exact(self): r""" Return whether all terms of this expansion are exact. @@ -2132,7 +2114,6 @@ def is_exact(self): """ return all(T.is_exact() for T in self.summands) - def is_little_o_of_one(self): r""" Return whether this expansion is of order `o(1)`. @@ -2173,7 +2154,6 @@ def is_little_o_of_one(self): """ return all(term.is_little_o_of_one() for term in self.summands.maximal_elements()) - def rpow(self, base, precision=None, locals=None): r""" Return the power of ``base`` to this asymptotic expansion. @@ -2290,7 +2270,6 @@ def inverted_factorials(): return result * large_result - def _main_term_relative_error_(self, return_inverse_main_term=False): r""" Split this asymptotic expansion into `m(1+x)` with `x=o(1)`. @@ -2363,7 +2342,6 @@ def _main_term_relative_error_(self, return_inverse_main_term=False): else: return (max_elem, x) - @staticmethod def _power_series_(coefficients, start, ratio, ratio_start, precision): r""" @@ -2438,7 +2416,6 @@ def _power_series_(coefficients, start, ratio, ratio_start, precision): result = new_result return result - def exp(self, precision=None): r""" Return the exponential of (i.e., the power of `e` to) this asymptotic expansion. @@ -2508,7 +2485,6 @@ def exp(self, precision=None): """ return self.rpow('e', precision=precision) - def substitute(self, rules=None, domain=None, **kwds): r""" Substitute the given ``rules`` in this asymptotic expansion. @@ -2669,7 +2645,7 @@ def substitute(self, rules=None, domain=None, **kwds): # init and process keyword arguments gens = self.parent().gens() - locals = kwds or dict() + locals = kwds or {} # update with rules if isinstance(rules, dict): @@ -2784,7 +2760,6 @@ def _substitute_(self, rules): from .misc import substitute_raise_exception substitute_raise_exception(self, e) - def compare_with_values(self, variable, function, values, rescaled=True, ring=RIF): """ @@ -2944,7 +2919,6 @@ def function(arg): return points - def plot_comparison(self, variable, function, values, rescaled=True, ring=RIF, relative_tolerance=0.025, **kwargs): r""" @@ -3041,7 +3015,6 @@ def plot_comparison(self, variable, function, values, rescaled=True, return list_plot(points, **kwargs) - def symbolic_expression(self, R=None): r""" Return this asymptotic expansion as a symbolic expression. @@ -3096,10 +3069,8 @@ def symbolic_expression(self, R=None): for g in self.parent().gens()), domain=R) - _symbolic_ = symbolic_expression # will be used by SR._element_constructor_ - def map_coefficients(self, f, new_coefficient_ring=None): r""" Return the asymptotic expansion obtained by applying ``f`` to @@ -3154,7 +3125,6 @@ def mapping(term): S.map(mapping) return P(S, simplify=False, convert=False) - def factorial(self): r""" Return the factorial of this asymptotic expansion. @@ -3256,7 +3226,6 @@ def factorial(self): 'Cannot build the factorial of {} since it is not ' 'univariate.'.format(self)) - def variable_names(self): r""" Return the names of the variables of this asymptotic expansion. @@ -3291,7 +3260,6 @@ def variable_names(self): from itertools import groupby return tuple(v for v, _ in groupby(vars)) - def _singularity_analysis_(self, var, zeta, precision=None): r""" Return the asymptotic growth of the coefficients of some @@ -3597,7 +3565,6 @@ class AsymptoticRing(Algebra, UniqueRepresentation, WithLocals): # enable the category framework for elements Element = AsymptoticExpansion - @staticmethod def __classcall__(cls, growth_group=None, coefficient_ring=None, names=None, category=None, default_prec=None, @@ -3736,12 +3703,11 @@ def format_names(N): if locals is not None: locals = cls._convert_locals_(locals) - return super(AsymptoticRing, - cls).__classcall__(cls, growth_group, coefficient_ring, - category=category, - default_prec=default_prec, - term_monoid_factory=term_monoid_factory, - locals=locals) + return super().__classcall__(cls, growth_group, coefficient_ring, + category=category, + default_prec=default_prec, + term_monoid_factory=term_monoid_factory, + locals=locals) def __init__(self, growth_group, coefficient_ring, category, default_prec, @@ -3770,9 +3736,8 @@ def __init__(self, growth_group, coefficient_ring, self._default_prec_ = default_prec self._term_monoid_factory_ = term_monoid_factory self._locals_ = locals - super(AsymptoticRing, self).__init__(base_ring=coefficient_ring, - category=category) - + super().__init__(base_ring=coefficient_ring, + category=category) @property def growth_group(self): @@ -3791,7 +3756,6 @@ def growth_group(self): """ return self._growth_group_ - @property def coefficient_ring(self): r""" @@ -3805,7 +3769,6 @@ def coefficient_ring(self): """ return self._coefficient_ring_ - @property def default_prec(self): r""" @@ -3826,7 +3789,6 @@ def default_prec(self): """ return self._default_prec_ - @property def term_monoid_factory(self): r""" @@ -3844,7 +3806,6 @@ def term_monoid_factory(self): """ return self._term_monoid_factory_ - def term_monoid(self, type): r""" Return the term monoid of this asymptotic ring of specified ``type``. @@ -3874,7 +3835,6 @@ def term_monoid(self, type): TermMonoid = self.term_monoid_factory return TermMonoid(type, asymptotic_ring=self) - def change_parameter(self, **kwds): r""" Return an asymptotic ring with a change in one or more of the given parameters. @@ -3908,7 +3868,7 @@ def change_parameter(self, **kwds): """ parameters = ('growth_group', 'coefficient_ring', 'default_prec', 'term_monoid_factory') - values = dict() + values = {} category = self.category() values['category'] = category locals = self._locals_ @@ -3998,7 +3958,6 @@ def _create_element_in_extension_(self, term, old_term_parent=None): coefficient_ring=term.parent().coefficient_ring) return parent(term, simplify=False, convert=False) - def _element_constructor_(self, data, simplify=True, convert=True): r""" Convert a given object to this asymptotic ring. @@ -4223,7 +4182,6 @@ def _element_constructor_(self, data, simplify=True, convert=True): return self.create_summand('exact', data) - def _coerce_map_from_(self, R): r""" Return whether ``R`` coerces into this asymptotic ring. @@ -4277,7 +4235,6 @@ def _coerce_map_from_(self, R): self.coefficient_ring.has_coerce_map_from(R.coefficient_ring): return True - def _repr_(self): r""" A representation string of this asymptotic ring. @@ -4303,7 +4260,6 @@ def _repr_(self): G = repr(self.growth_group) return 'Asymptotic Ring %s over %s' % (G, self.coefficient_ring) - def _an_element_(self): r""" Return an element of this asymptotic ring. @@ -4330,7 +4286,6 @@ def _an_element_(self): return self(E.an_element(), simplify=False, convert=False)**3 + \ self(O.an_element(), simplify=False, convert=False) - def some_elements(self): r""" Return some elements of this term monoid. @@ -4369,7 +4324,6 @@ def some_elements(self): for e, o in cantor_product( E.some_elements(), O.some_elements())) - def gens(self): r""" Return a tuple with generators of this asymptotic ring. @@ -4404,7 +4358,6 @@ def gens(self): coefficient=self.coefficient_ring(1)) for g in self.growth_group.gens_monomial()) - def gen(self, n=0): r""" Return the ``n``-th generator of this asymptotic ring. @@ -4425,7 +4378,6 @@ def gen(self, n=0): """ return self.gens()[n] - def ngens(self): r""" Return the number of generators of this asymptotic ring. @@ -4446,7 +4398,6 @@ def ngens(self): """ return len(self.growth_group.gens_monomial()) - def coefficients_of_generating_function(self, function, singularities, precision=None, return_singular_expansions=False, error_term=None): @@ -4592,7 +4543,6 @@ def coefficients_of_generating_function(self, function, singularities, precision else: return result - def create_summand(self, type, data=None, **kwds): r""" Create a simple asymptotic expansion consisting of a single @@ -4686,7 +4636,6 @@ def create_summand(self, type, data=None, **kwds): except ZeroCoefficientError: return self.zero() - def variable_names(self): r""" Return the names of the variables. @@ -4703,7 +4652,6 @@ def variable_names(self): """ return self.growth_group.variable_names() - def construction(self): r""" Return the construction of this asymptotic ring. @@ -4822,7 +4770,6 @@ class AsymptoticRingFunctor(ConstructionFunctor): rank = 13 - def __init__(self, growth_group, default_prec=None, category=None, term_monoid_factory=None, locals=None, @@ -4848,9 +4795,7 @@ def __init__(self, growth_group, self._locals_ = locals from sage.categories.rings import Rings - super(ConstructionFunctor, self).__init__( - Rings(), Rings()) - + super().__init__(Rings(), Rings()) def _repr_(self): r""" @@ -4877,7 +4822,6 @@ def _repr_(self): return '{}<{}>'.format(self.cls.__name__, self.growth_group._repr_(condense=True)) - def _apply_functor(self, coefficient_ring): r""" Apply this functor to the given ``coefficient_ring``. @@ -4930,7 +4874,6 @@ def _apply_functor(self, coefficient_ring): kwds[parameter] = value return self.cls(**kwds) - def merge(self, other): r""" Merge this functor with ``other`` if possible. @@ -5027,7 +4970,6 @@ def merge(self, other): category=category, cls=self.cls) - def __eq__(self, other): r""" Return whether this functor is equal to ``other``. @@ -5057,7 +4999,6 @@ def __eq__(self, other): and self._category_ == other._category_ and self.cls == other.cls) - def __ne__(self, other): r""" Return whether this functor is not equal to ``other``. diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py index e80235a7d9d..ec4c5ce878f 100644 --- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py @@ -336,7 +336,7 @@ def __init__(self, parent, numerator, denominator_factored, reduce=True): sage: f = FFPD(x, df) sage: TestSuite(f).run() """ - super(FractionWithFactoredDenominator, self).__init__(parent) + super().__init__(parent) from sage.rings.semirings.non_negative_integer_semiring import NN self._numerator = parent._numerator_ring(numerator) @@ -1940,7 +1940,7 @@ def asymptotics_smooth(self, p, alpha, N, asy_var, coordinate=None, sub_final=[Tstar, atP], rekey=AA) Phitu_derivs = diff_all(Phitu, T, N - 1 + v, sub=hderivs1, sub_final=[Tstar, atP], - zero_order=v + 1 , rekey=BB) + zero_order=v + 1, rekey=BB) AABB_derivs = At_derivs AABB_derivs.update(Phitu_derivs) AABB_derivs[AA] = At.subs(Tstar).subs(atP) @@ -2007,7 +2007,7 @@ def asymptotics_smooth(self, p, alpha, N, asy_var, coordinate=None, AABB_derivs[BB] = Phitu.subs(Tstar).subs(atP) if verbose: print("Computing second order differential operator actions...") - DD = diff_op(AA, BB, AABB_derivs, T, a_inv, 1 , N) + DD = diff_op(AA, BB, AABB_derivs, T, a_inv, 1, N) # Plug above into asymptotic formula. L = [] @@ -3066,8 +3066,8 @@ def __classcall_private__(cls, denominator_ring, numerator_ring=None, category=N 'denominator ring {}'.format( numerator_ring, denominator_ring)) category = Rings().or_subcategory(category) - return super(FractionWithFactoredDenominatorRing, cls).__classcall__(cls, - denominator_ring, numerator_ring, category) + return super().__classcall__(cls, denominator_ring, + numerator_ring, category) def __init__(self, denominator_ring, numerator_ring=None, category=None): r""" @@ -3792,7 +3792,7 @@ def subs_all(f, sub, simplify=False): sage: var('x, y') (x, y) sage: a = {'foo': x**2 + y**2, 'bar': x - y} - sage: b = {x: 1 , y: 2} + sage: b = {x: 1, y: 2} sage: subs_all(a, b) {'bar': -1, 'foo': 5} """ diff --git a/src/sage/rings/asymptotic/growth_group_cartesian.py b/src/sage/rings/asymptotic/growth_group_cartesian.py index 3f2e6d7e692..645d9723e68 100644 --- a/src/sage/rings/asymptotic/growth_group_cartesian.py +++ b/src/sage/rings/asymptotic/growth_group_cartesian.py @@ -512,7 +512,7 @@ def convert_factors(data, raw_data): # room for other parents (e.g. polynomial ring et al.) try: - return super(GenericProduct, self)._element_constructor_(data) + return super()._element_constructor_(data) except (TypeError, ValueError): pass if isinstance(data, (tuple, list, CartesianProduct.Element)): @@ -1441,9 +1441,7 @@ def __init__(self, sets, category, **kwargs): sage: type(GrowthGroup('x^ZZ * log(x)^ZZ')) # indirect doctest """ - super(UnivariateProduct, self).__init__( - sets, category, order='lex', **kwargs) - + super().__init__(sets, category, order='lex', **kwargs) CartesianProduct = CartesianProductGrowthGroups @@ -1474,8 +1472,6 @@ def __init__(self, sets, category, **kwargs): sage: type(GrowthGroup('x^ZZ * y^ZZ')) # indirect doctest """ - super(MultivariateProduct, self).__init__( - sets, category, order='product', **kwargs) - + super().__init__(sets, category, order='product', **kwargs) CartesianProduct = CartesianProductGrowthGroups diff --git a/src/sage/rings/asymptotic/misc.py b/src/sage/rings/asymptotic/misc.py index 33388f9f183..8117d8ede30 100644 --- a/src/sage/rings/asymptotic/misc.py +++ b/src/sage/rings/asymptotic/misc.py @@ -17,7 +17,7 @@ ============================== """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2015 Daniel Krenn # # This program is free software: you can redistribute it and/or modify @@ -25,8 +25,7 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # https://www.gnu.org/licenses/ -#***************************************************************************** - +# **************************************************************************** from sage.misc.cachefunc import cached_method from sage.structure.sage_object import SageObject @@ -269,7 +268,7 @@ def is_balanced(s): return False return bool(open == 0) - factors = list() + factors = [] balanced = True if string and op is not None and string.startswith(op): raise ValueError("'%s' is invalid since it starts with a '%s'." % @@ -357,10 +356,8 @@ def add_parentheses(s, op): if any(sig in s for sig in signals) or latex and s.startswith(r'\frac'): if latex: return r'\left({}\right)'.format(s) - else: - return '({})'.format(s) - else: - return s + return '({})'.format(s) + return s return add_parentheses(left, op) + op + add_parentheses(right, op) @@ -843,7 +840,7 @@ def __init__(self, asymptotic_ring=None, var=None, exact_part=0): exact_part = asymptotic_ring.zero() self.exact_part = exact_part - super(NotImplementedOZero, self).__init__(message) + super().__init__(message) class NotImplementedBZero(NotImplementedError): @@ -913,7 +910,7 @@ def __init__(self, asymptotic_ring=None, var=None, exact_part=0): exact_part = asymptotic_ring.zero() self.exact_part = exact_part - super(NotImplementedBZero, self).__init__(message) + super().__init__(message) def transform_category(category, @@ -1081,7 +1078,7 @@ def __getitem__(self, key): """ try: - return super(Locals, self).__getitem__(key) + return super().__getitem__(key) except KeyError as ke: try: return self.default_locals()[key] @@ -1188,8 +1185,7 @@ def _convert_locals_(locals): """ if locals is None: return Locals() - else: - return Locals(locals) + return Locals(locals) def locals(self, locals=None): r""" diff --git a/src/sage/rings/asymptotic/term_monoid.py b/src/sage/rings/asymptotic/term_monoid.py index 36b3d2e4f33..b5b39091371 100644 --- a/src/sage/rings/asymptotic/term_monoid.py +++ b/src/sage/rings/asymptotic/term_monoid.py @@ -1864,7 +1864,7 @@ def _element_constructor_(self, data, *args, **kwds): f'takes one positional argument, ' f'another positional argument is deprecated, ' f'but {len(args)+1} were given') - elif len(args) == 1: + if len(args) == 1: from sage.misc.superseded import deprecation deprecation(32215, "Passing 'coefficient' as a positional argument is deprecated; " @@ -4877,7 +4877,7 @@ def _absorb_(self, other): if not (self.growth >= other.growth): raise ArithmeticError(f'{self} cannot absorb {other}') - valid_from_new = dict() + valid_from_new = {} for variable_name in set().union(self.valid_from.keys(), other.valid_from.keys()): if variable_name in self.valid_from and other.valid_from: valid_from_new[variable_name] = (max(self.valid_from[variable_name], other.valid_from[variable_name])) @@ -5339,7 +5339,7 @@ def __init__(self, name, sage: type(MyTermMonoid('B', G, QQ)) """ - super(TermMonoidFactory, self).__init__(name) + super().__init__(name) if exact_term_monoid_class is None: exact_term_monoid_class = ExactTermMonoid From cc504c598b2358603025df90f8c8ebce315c327f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 6 Aug 2022 18:10:56 +0200 Subject: [PATCH 2/4] oops --- src/sage/combinat/crystals/fast_crystals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/crystals/fast_crystals.py b/src/sage/combinat/crystals/fast_crystals.py index 9899f87122b..86e3d39cfc3 100644 --- a/src/sage/combinat/crystals/fast_crystals.py +++ b/src/sage/combinat/crystals/fast_crystals.py @@ -1,4 +1,4 @@ -sr""" +r""" Fast Rank Two Crystals """ # **************************************************************************** From b19a6aa1e86fa17a4d4c1ee0934780126ead2fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 7 Aug 2022 10:43:28 +0200 Subject: [PATCH 3/4] fix in crystal of letters --- src/sage/combinat/crystals/letters.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/crystals/letters.pyx b/src/sage/combinat/crystals/letters.pyx index ccd57d461bf..8eec7d22067 100644 --- a/src/sage/combinat/crystals/letters.pyx +++ b/src/sage/combinat/crystals/letters.pyx @@ -167,7 +167,7 @@ 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().__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 @@ -175,7 +175,7 @@ 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().__iter__()] + self._list = list(super(ClassicalCrystalOfLetters, self).__iter__()) else: self.module_generators = (self._element_constructor_(1),) if cartan_type.type() == 'G': From d4bf07b52c849cbe8e3ec2782994beb7e156d121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 7 Aug 2022 19:04:49 +0200 Subject: [PATCH 4/4] fix wrong change --- src/sage/combinat/crystals/monomial_crystals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/crystals/monomial_crystals.py b/src/sage/combinat/crystals/monomial_crystals.py index 9accb0195e5..5179ffd1a76 100644 --- a/src/sage/combinat/crystals/monomial_crystals.py +++ b/src/sage/combinat/crystals/monomial_crystals.py @@ -1252,6 +1252,6 @@ def cardinality(self): """ if not self.cartan_type().is_finite(): return Infinity - return super().cardinality() + return super(InfinityCrystalOfNakajimaMonomials, self).cardinality() Element = CrystalOfNakajimaMonomialsElement