Skip to content

let shorthands be tuple and immutable #40271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/sage/algebras/iwahori_hecke_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,17 @@ def __init__(self, W, q1, q2, base_ring):
# Attach the generic Hecke algebra and the basis change maps
self._root = root
self._generic_iwahori_hecke_algebra = IwahoriHeckeAlgebra_nonstandard(W)
self._shorthands = ['C', 'Cp', 'T']
self._shorthands = ('C', 'Cp', 'T')
else:
# Can we actually remove the bases C and Cp in this case?
self._root = None
self._shorthands = ['T']
self._shorthands = ('T',)

# if 2 is a unit in the base ring then add th A and B bases
try:
base_ring(base_ring.one() / 2)
self._shorthands.extend(['A', 'B'])
sh = self._shorthands
self._shorthands = (*sh, 'A', 'B')
except (TypeError, ZeroDivisionError):
pass

Expand Down Expand Up @@ -2785,7 +2786,7 @@ def __init__(self, W):
self.u_inv = normalized_laurent_polynomial(base_ring, u**-1)
self.v_inv = normalized_laurent_polynomial(base_ring, v**-1)

self._shorthands = ['C', 'Cp', 'T']
self._shorthands = ('C', 'Cp', 'T')

if W.is_finite():
self._category = FiniteDimensionalAlgebrasWithBasis(base_ring)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/with_realizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __init__(self, R, S):
F_to_Out .register_as_coercion()
(~F_to_Out).register_as_coercion()

_shorthands = ["F", "In", "Out"]
_shorthands = ("F", "In", "Out")

def a_realization(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/chas/fsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def __init__(self, base_ring):
cat = HopfAlgebras(base_ring).Graded().Connected()
Parent.__init__(self, base=base_ring, category=cat.WithRealizations())

_shorthands = ['G']
_shorthands = ('G',)

def a_realization(self):
r"""
Expand Down Expand Up @@ -790,7 +790,7 @@ class FreeSymmetricFunctions_Dual(UniqueRepresentation, Parent):
sage: TF(F[[5, 1, 4, 2, 3]])
F[135|2|4]
"""
def __init__(self, base_ring):
def __init__(self, base_ring) -> None:
r"""
Initialize ``self``.

Expand All @@ -802,7 +802,7 @@ def __init__(self, base_ring):
cat = HopfAlgebras(base_ring).Graded().Connected()
Parent.__init__(self, base=base_ring, category=cat.WithRealizations())

_shorthands = ['F']
_shorthands = ('F',)

def a_realization(self):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/chas/wqsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def a_realization(self):
"""
return self.M()

_shorthands = tuple(['M', 'X', 'C', 'Q', 'Phi'])
_shorthands = ('M', 'X', 'C', 'Q', 'Phi')

# add options to class
class options(GlobalOptions):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/fqsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def a_realization(self):
"""
return self.F()

_shorthands = tuple(['F', 'G', 'M'])
_shorthands = ('F', 'G', 'M')

class F(FQSymBasis_abstract):
r"""
Expand Down
7 changes: 4 additions & 3 deletions src/sage/combinat/ncsf_qsym/ncsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class NonCommutativeSymmetricFunctions(UniqueRepresentation, Parent):
sage: TestSuite(complete).run()
"""

def __init__(self, R):
def __init__(self, R) -> None:
r"""
TESTS::

Expand Down Expand Up @@ -445,7 +445,7 @@ def __init__(self, R):
Phi.algebra_morphism(Phi._to_complete_on_generators,
codomain=complete).register_as_coercion()

def _repr_(self): # could be taken care of by the category
def _repr_(self) -> str: # could be taken care of by the category
r"""
EXAMPLES::

Expand All @@ -472,7 +472,8 @@ def a_realization(self):
"""
return self.complete()

_shorthands = tuple(['S', 'R', 'L', 'Phi', 'Psi', 'nM', 'I', 'dQS', 'dYQS', 'ZL', 'ZR'])
_shorthands = ('S', 'R', 'L', 'Phi', 'Psi', 'nM', 'I',
'dQS', 'dYQS', 'ZL', 'ZR')

def dual(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/ncsf_qsym/qsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class QuasiSymmetricFunctions(UniqueRepresentation, Parent):
True
"""

def __init__(self, R):
def __init__(self, R) -> None:
"""
The Hopf algebra of quasi-symmetric functions.
See ``QuasiSymmetricFunctions`` for full documentation.
Expand Down Expand Up @@ -609,7 +609,7 @@ def __init__(self, R):
codomain=Fundamental, category=category)
Sym_s_to_F.register_as_coercion()

def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

Expand All @@ -632,7 +632,7 @@ def a_realization(self):
"""
return self.Monomial()

_shorthands = tuple(['M', 'F', 'E', 'dI', 'QS', 'YQS', 'phi', 'psi'])
_shorthands = ('M', 'F', 'E', 'dI', 'QS', 'YQS', 'phi', 'psi')

def dual(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/ncsym/ncsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class SymmetricFunctionsNonCommutingVariables(UniqueRepresentation, Parent):
-4*p[] + 2*p[1] + p[2, 2]
"""

def __init__(self, R):
def __init__(self, R) -> None:
"""
Initialize ``self``.

Expand All @@ -309,7 +309,7 @@ def __init__(self, R):
category = GradedHopfAlgebras(R).Cocommutative()
Parent.__init__(self, category=category.WithRealizations())

def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

Expand All @@ -331,7 +331,7 @@ def a_realization(self):
"""
return self.powersum()

_shorthands = tuple(['chi', 'cp', 'm', 'e', 'h', 'p', 'rho', 'x'])
_shorthands = ('chi', 'cp', 'm', 'e', 'h', 'p', 'rho', 'x')

def dual(self):
r"""
Expand Down
36 changes: 19 additions & 17 deletions src/sage/combinat/sf/sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Symmetric functions, with their multiple realizations
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2007 Mike Hansen <[email protected]>
# 2009-2012 Jason Bandlow <[email protected]>
# 2012 Anne Schilling <anne at math.ucdavis.edu>
Expand All @@ -18,8 +18,8 @@
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ***************************************************************************
from sage.categories.fields import Fields
from sage.categories.graded_hopf_algebras import GradedHopfAlgebras
from sage.categories.principal_ideal_domains import PrincipalIdealDomains
Expand Down Expand Up @@ -885,7 +885,7 @@ def a_realization(self):
"""
return self.schur()

def _repr_(self): # could be taken care of by the category
def _repr_(self): # could be taken care of by the category
r"""
Representation of ``self``

Expand All @@ -907,7 +907,7 @@ def schur(self):
"""
return schur.SymmetricFunctionAlgebra_schur(self)
s = schur
Schur = schur # Currently needed by SymmetricFunctions.__init_extra__
Schur = schur # Currently needed by SymmetricFunctions.__init_extra__

def powersum(self):
r"""
Expand All @@ -920,7 +920,8 @@ def powersum(self):
"""
return powersum.SymmetricFunctionAlgebra_power(self)
p = powersum
power = powersum # Todo: get rid of this one when it won't be needed anymore
power = powersum
# Todo: get rid of the line above when it won't be needed anymore

def complete(self):
r"""
Expand Down Expand Up @@ -1321,7 +1322,7 @@ def jack(self, t='t'):
sage: JQp = Sym.jack().Qp(); JQp
Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack Qp basis
"""
return jack.Jack( self, t=t )
return jack.Jack(self, t=t)

def abreu_nigro(self, q='q'):
"""
Expand All @@ -1345,7 +1346,7 @@ def zonal(self):
sage: SymmetricFunctions(QQ).zonal()
Symmetric Functions over Rational Field in the zonal basis
"""
return jack.SymmetricFunctionAlgebra_zonal( self )
return jack.SymmetricFunctionAlgebra_zonal(self)

def llt(self, k, t='t'):
"""
Expand All @@ -1369,7 +1370,7 @@ def llt(self, k, t='t'):
sage: llt3.hcospin()
Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT cospin basis
"""
return llt.LLT_class( self, k, t=t )
return llt.LLT_class(self, k, t=t)

def from_polynomial(self, f):
"""
Expand Down Expand Up @@ -1430,8 +1431,9 @@ def register_isomorphism(self, morphism, only_conversion=False):
else:
morphism.codomain().register_coercion(morphism)

_shorthands = ['e', 'f', 'h', 'm', 'p', 's']
_shorthands_all = sorted(_shorthands + ['ht', 'o', 'sp', 'st', 'w'])
# keep them sorted in alphabetic order
_shorthands = ('e', 'f', 'h', 'm', 'p', 's')
_shorthands_all = ('e', 'f', 'h', 'ht', 'm', 'o', 'p', 's', 'sp', 'st', 'w')

def __init_extra__(self):
"""
Expand All @@ -1452,11 +1454,11 @@ def __init_extra__(self):
sage: f(p.an_element()) == p.an_element()
True
"""
#powersum = self.powersum ()
#complete = self.complete ()
#elementary = self.elementary()
#schur = self.schur ()
#monomial = self.monomial ()
# powersum = self.powersum ()
# complete = self.complete ()
# elementary = self.elementary()
# schur = self.schur ()
# monomial = self.monomial ()

iso = self.register_isomorphism

Expand All @@ -1465,7 +1467,7 @@ def __init_extra__(self):
for (basis1_name, basis2_name) in conversion_functions:
basis1 = getattr(self, basis1_name)()
basis2 = getattr(self, basis2_name)()
on_basis = SymmetricaConversionOnBasis(t=conversion_functions[basis1_name,basis2_name], domain=basis1, codomain=basis2)
on_basis = SymmetricaConversionOnBasis(t=conversion_functions[basis1_name, basis2_name], domain=basis1, codomain=basis2)
from sage.rings.rational_field import RationalField
if basis2_name != "powersum" or self._base.has_coerce_map_from(RationalField()):
iso(basis1._module_morphism(on_basis, codomain=basis2))
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/integer_valued_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IntegerValuedPolynomialRing(UniqueRepresentation, Parent):
...
TypeError: argument R must be a commutative ring
"""
def __init__(self, R):
def __init__(self, R) -> None:
"""
TESTS::

Expand All @@ -88,7 +88,7 @@ def __init__(self, R):
cat = Algebras(R).Commutative().WithBasis()
Parent.__init__(self, base=R, category=cat.WithRealizations())

_shorthands = ["B", "S"]
_shorthands = ("B", "S")

def _repr_(self) -> str:
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/q_integer_valued_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __init__(self, R, q) -> None:
cat = Algebras(R).Commutative().WithBasis()
Parent.__init__(self, base=R, category=cat.WithRealizations())

_shorthands = ["B", "S"]
_shorthands = ("B", "S")

def _repr_(self) -> str:
r"""
Expand Down
Loading