Skip to content

Commit d22a144

Browse files
author
Release Manager
committed
Trac #34142: modernize super in algebras/
using the short syntax `super()` URL: https://trac.sagemath.org/34142 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Matthias Koeppe
2 parents 4885449 + 72f124d commit d22a144

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+152
-158
lines changed

src/sage/algebras/askey_wilson.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def __classcall_private__(cls, R, q=None):
237237
raise ValueError("q={} is not invertible in {}".format(q, R))
238238
if R not in Rings().Commutative():
239239
raise ValueError("{} is not a commutative ring".format(R))
240-
return super(AskeyWilsonAlgebra, cls).__classcall__(cls, R, q)
240+
return super().__classcall__(cls, R, q)
241241

242242
def __init__(self, R, q):
243243
r"""
@@ -932,4 +932,4 @@ def _composition_(self, right, homset):
932932
return AlgebraMorphism(homset.domain(),
933933
[right(g) for g in self._on_generators],
934934
codomain=homset.codomain(), category=cat)
935-
return super(self, AlgebraMorphism)._composition_(right, homset)
935+
return super()._composition_(right, homset)

src/sage/algebras/associated_graded.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def _element_constructor_(self, x):
249249
if isinstance(x, CombinatorialFreeModule.Element):
250250
if x.parent() is self._A:
251251
return self._from_dict(dict(x))
252-
return super(AssociatedGradedAlgebra, self)._element_constructor_(x)
252+
return super()._element_constructor_(x)
253253

254254
def gen(self, *args, **kwds):
255255
"""

src/sage/algebras/clifford_algebra.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def __classcall_private__(cls, Q, names=None):
463463
names = tuple( '{}{}'.format(names[0], i) for i in range(Q.dim()) )
464464
else:
465465
raise ValueError("the number of variables does not match the number of generators")
466-
return super(CliffordAlgebra, cls).__classcall__(cls, Q, names)
466+
return super().__classcall__(cls, Q, names)
467467

468468
def __init__(self, Q, names, category=None):
469469
r"""
@@ -637,7 +637,7 @@ def _coerce_map_from_(self, V):
637637
if self.free_module().has_coerce_map_from(V):
638638
return True
639639

640-
return super(CliffordAlgebra, self)._coerce_map_from_(V)
640+
return super()._coerce_map_from_(V)
641641

642642
def _element_constructor_(self, x):
643643
"""
@@ -682,7 +682,7 @@ def _element_constructor_(self, x):
682682
R = self.base_ring()
683683
return self.element_class(self, {i: R(c) for i,c in x if R(c) != R.zero()})
684684

685-
return super(CliffordAlgebra, self)._element_constructor_(x)
685+
return super()._element_constructor_(x)
686686

687687
def gen(self, i):
688688
"""
@@ -1369,7 +1369,7 @@ def __classcall_private__(cls, R, names=None, n=None):
13691369
names = tuple( '{}{}'.format(names[0], i) for i in range(n) )
13701370
else:
13711371
raise ValueError("the number of variables does not match the number of generators")
1372-
return super(ExteriorAlgebra, cls).__classcall__(cls, R, names)
1372+
return super().__classcall__(cls, R, names)
13731373

13741374
def __init__(self, R, names):
13751375
"""
@@ -2211,7 +2211,7 @@ def __classcall__(cls, E, s_coeff):
22112211

22122212
if isinstance(v, dict):
22132213
R = E.base_ring()
2214-
v = E._from_dict({(i,): R(c) for i,c in v.items()})
2214+
v = E._from_dict({(i,): R(c) for i, c in v.items()})
22152215
else:
22162216
# Make sure v is in ``E``
22172217
v = E(v)
@@ -2227,7 +2227,7 @@ def __classcall__(cls, E, s_coeff):
22272227
d[(k[1], k[0])] = -v
22282228

22292229
from sage.sets.family import Family
2230-
return super(ExteriorAlgebraDifferential, cls).__classcall__(cls, E, Family(d))
2230+
return super().__classcall__(cls, E, Family(d))
22312231

22322232
def __init__(self, E, s_coeff):
22332233
"""

src/sage/algebras/cluster_algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ def __classcall__(self, data, **kwargs):
13381338
# Determine scalars
13391339
kwargs.setdefault('scalars', ZZ)
13401340

1341-
return super(ClusterAlgebra, self).__classcall__(self, B0, **kwargs)
1341+
return super().__classcall__(self, B0, **kwargs)
13421342

13431343
def __init__(self, B, **kwargs):
13441344
"""

src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def __classcall_private__(cls, k, table, names='e', assume_associative=False,
140140

141141
names = normalize_names(n, names)
142142

143-
return super(FiniteDimensionalAlgebra, cls).__classcall__(cls, k, table,
144-
names, category=cat)
143+
return super().__classcall__(cls, k, table,
144+
names, category=cat)
145145

146146
def __init__(self, k, table, names='e', category=None):
147147
"""
@@ -249,7 +249,7 @@ def _Hom_(self, B, category):
249249
if category.is_subcategory(cat):
250250
from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraHomset
251251
return FiniteDimensionalAlgebraHomset(self, B, category=category)
252-
return super(FiniteDimensionalAlgebra, self)._Hom_(B, category)
252+
return super()._Hom_(B, category)
253253

254254
def ngens(self):
255255
"""

src/sage/algebras/free_algebra.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def quotient(self, mons, mats=None, names=None, **args):
783783
Free algebra quotient on 3 generators ('i', 'j', 'k') and dimension 4 over Rational Field
784784
"""
785785
if mats is None:
786-
return super(FreeAlgebra_generic, self).quotient(mons, names)
786+
return super().quotient(mons, names)
787787
from . import free_algebra_quotient
788788
return free_algebra_quotient.FreeAlgebraQuotient(self, mons, mats, names)
789789

@@ -1088,7 +1088,7 @@ def __classcall_private__(cls, R, n=None, names=None):
10881088
if n is None:
10891089
n = len(names)
10901090
alg = FreeAlgebra(R, n, names)
1091-
return super(PBWBasisOfFreeAlgebra, cls).__classcall__(cls, alg)
1091+
return super().__classcall__(cls, alg)
10921092

10931093
def __init__(self, alg):
10941094
"""
@@ -1137,7 +1137,7 @@ def _repr_term(self, w):
11371137
3*PBW[1]
11381138
"""
11391139
if len(w) == 0:
1140-
return super(PBWBasisOfFreeAlgebra, self)._repr_term(w)
1140+
return super()._repr_term(w)
11411141
ret = ''
11421142
p = 1
11431143
cur = None
@@ -1149,7 +1149,7 @@ def _repr_term(self, w):
11491149
if p != 1:
11501150
ret += "^{}".format(p)
11511151
ret += "*"
1152-
ret += super(PBWBasisOfFreeAlgebra, self)._repr_term(x.to_monoid_element())
1152+
ret += super()._repr_term(x.to_monoid_element())
11531153
cur = x
11541154
p = 1
11551155
if p != 1:

src/sage/algebras/free_algebra_element.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ def _acted_upon_(self, scalar, self_on_left=False):
224224
if self_on_left:
225225
return Factorization([(self, 1)]) * scalar
226226
return scalar * Factorization([(self, 1)])
227-
return super(FreeAlgebraElement, self)._acted_upon_(scalar, self_on_left)
227+
return super()._acted_upon_(scalar, self_on_left)
228228

229229
# For backward compatibility
230-
#_lmul_ = _acted_upon_
231-
#_rmul_ = _acted_upon_
230+
# _lmul_ = _acted_upon_
231+
# _rmul_ = _acted_upon_
232232

233233
def variables(self):
234234
"""

src/sage/algebras/free_algebra_quotient.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ def __classcall__(cls, A, mons, mats, names):
8383
M = M.parent()(M)
8484
M.set_immutable()
8585
new_mats.append(M)
86-
return super(FreeAlgebraQuotient, cls).__classcall__(cls, A, tuple(mons),
87-
tuple(new_mats), tuple(names))
86+
return super().__classcall__(cls, A, tuple(mons),
87+
tuple(new_mats), tuple(names))
8888

8989
Element = FreeAlgebraQuotientElement
90+
9091
def __init__(self, A, mons, mats, names):
9192
"""
9293
Return a quotient algebra defined via the action of a free algebra

src/sage/algebras/free_zinbiel_algebra.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,9 @@ def __classcall_private__(cls, R, n=None, names=None,
211211
side = '<'
212212
if side not in ['<', '>']:
213213
raise ValueError("side must be either '<' or '>'")
214-
superclass = super(FreeZinbielAlgebra, cls)
215214
if names is None:
216-
return superclass.__classcall__(cls, R, n, None, prefix, side)
217-
return superclass.__classcall__(cls, R, n, tuple(names), prefix, side)
215+
return super().__classcall__(cls, R, n, None, prefix, side)
216+
return super().__classcall__(cls, R, n, tuple(names), prefix, side)
218217

219218
def __init__(self, R, n, names, prefix, side):
220219
"""
@@ -603,7 +602,7 @@ def _coerce_map_from_(self, R):
603602
return (all(x in self.variable_names()
604603
for x in R.variable_names()) and
605604
self.base_ring().has_coerce_map_from(R.base_ring()))
606-
return super(FreeZinbielAlgebra, self)._coerce_map_from_(R)
605+
return super()._coerce_map_from_(R)
607606

608607
def construction(self):
609608
"""

src/sage/algebras/hecke_algebras/ariki_koike_algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def __classcall_private__(cls, r, n, q=None, u=None, R=None):
311311
raise TypeError("base ring must be a commutative ring")
312312
q = R(q)
313313
u = tuple(u)
314-
return super(ArikiKoikeAlgebra, cls).__classcall__(cls, r, n, q, u, R)
314+
return super().__classcall__(cls, r, n, q, u, R)
315315

316316
def __init__(self, r, n, q, u, R):
317317
r"""

0 commit comments

Comments
 (0)