Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ test = ["coverage", "pytest", "pytest-xdist"]
# Python 3.12 is the minimum supported version
target-version = "py312"

line-length = 320


exclude = [
# This directory is full of old autogenerated files.
# Linting it would just get in the way of adding stricter linter rules
Expand All @@ -261,6 +264,9 @@ exclude = [
"build/",
]

[tool.ruff.format]
quote-style = "preserve"

[tool.ruff.lint]

# Rules that we deliberately do not attempt to follow, either because we
Expand Down
4 changes: 2 additions & 2 deletions src/sage/algebras/affine_nil_temperley_lieb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Affine nilTemperley Lieb Algebra of type A
"""

# ****************************************************************************
# Copyright (C) 2010 Anne Schilling <anne at math.ucdavis.edu>
#
Expand Down Expand Up @@ -234,8 +235,7 @@ def has_no_braid_relation(self, w, i) -> bool:
return False
s = w.parent().simple_reflections()
wi = w * s[i]
adjacent = [(i - 1) % w.parent().n,
(i + 1) % w.parent().n]
adjacent = [(i - 1) % w.parent().n, (i + 1) % w.parent().n]
for j in adjacent:
if j in w.descents():
return j not in wi.descents()
Expand Down
10 changes: 4 additions & 6 deletions src/sage/algebras/all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Algebras
"""

# ****************************************************************************
# Copyright (C) 2005 William Stein <wstein@gmail.com>
#
Expand Down Expand Up @@ -38,11 +39,9 @@
lazy_import('sage.algebras.group_algebra', 'GroupAlgebra')

lazy_import('sage.algebras.iwahori_hecke_algebra', 'IwahoriHeckeAlgebra')
lazy_import('sage.algebras.affine_nil_temperley_lieb',
'AffineNilTemperleyLiebTypeA')
lazy_import('sage.algebras.affine_nil_temperley_lieb', 'AffineNilTemperleyLiebTypeA')
lazy_import('sage.algebras.nil_coxeter_algebra', 'NilCoxeterAlgebra')
lazy_import('sage.algebras.schur_algebra', ['SchurAlgebra',
'SchurTensorModule'])
lazy_import('sage.algebras.schur_algebra', ['SchurAlgebra', 'SchurTensorModule'])

lazy_import('sage.algebras.hall_algebra', 'HallAlgebra')

Expand All @@ -57,8 +56,7 @@

lazy_import('sage.algebras.commutative_dga', 'GradedCommutativeAlgebra')

lazy_import('sage.algebras.rational_cherednik_algebra',
'RationalCherednikAlgebra')
lazy_import('sage.algebras.rational_cherednik_algebra', 'RationalCherednikAlgebra')

lazy_import('sage.algebras.tensor_algebra', 'TensorAlgebra')

Expand Down
93 changes: 35 additions & 58 deletions src/sage/algebras/askey_wilson.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class AskeyWilsonAlgebra(CombinatorialFreeModule):

- [Terwilliger2011]_
"""

@staticmethod
def __classcall_private__(cls, R, q=None):
r"""
Expand Down Expand Up @@ -250,11 +251,8 @@ def __init__(self, R, q) -> None:
"""
self._q = q
cat = Algebras(Rings().Commutative()).WithBasis()
indices = cartesian_product([NonNegativeIntegers()]*6)
CombinatorialFreeModule.__init__(self, R, indices, prefix='AW',
sorting_key=_basis_key,
sorting_reverse=True,
category=cat)
indices = cartesian_product([NonNegativeIntegers()] * 6)
CombinatorialFreeModule.__init__(self, R, indices, prefix='AW', sorting_key=_basis_key, sorting_reverse=True, category=cat)
self._assign_names('A,B,C,a,b,g')

def _repr_term(self, t) -> str:
Expand All @@ -271,12 +269,14 @@ def _repr_term(self, t) -> str:
sage: AW._repr_term((0,1,0,3,7,2))
'B*a^3*b^7*g^2'
"""

def exp(l, e):
if e == 0:
return ''
if e == 1:
return '*' + l
return '*' + l + '^{}'.format(e)

ret = ''.join(exp(l, e) for l, e in zip('ABCabg', t))
if not ret:
return '1'
Expand Down Expand Up @@ -307,6 +307,7 @@ def exp(l, e):
if e == 1:
return l
return l + '^{{{}}}'.format(e)

var_names = ['A', 'B', 'C', '\\alpha', '\\beta', '\\gamma']
return ''.join(exp(l, e) for l, e in zip(var_names, t))

Expand Down Expand Up @@ -344,6 +345,7 @@ def build_monomial(g):
exp = [0] * 6
exp[A.index(g)] = 1
return self.monomial(self._indices(exp))

return Family(A, build_monomial)

@cached_method
Expand All @@ -370,7 +372,7 @@ def one_basis(self):
sage: AW.one_basis()
(0, 0, 0, 0, 0, 0)
"""
return self._indices([0]*6)
return self._indices([0] * 6)

def q(self):
r"""
Expand Down Expand Up @@ -401,10 +403,7 @@ def _an_element_(self):
q = self._q
I = self._indices
R = self.base_ring()
elt = {I((1,0,0,0,0,0)): R(1),
I((1,0,2,0,1,0)): R.an_element(),
I((0,1,0,2,0,1)): q**2 * R(3),
I((0,0,0,1,1,3)): q**-3 + R(3) + R(2)*q + q**2}
elt = {I((1, 0, 0, 0, 0, 0)): R(1), I((1, 0, 2, 0, 1, 0)): R.an_element(), I((0, 1, 0, 2, 0, 1)): q**2 * R(3), I((0, 0, 0, 1, 1, 3)): q**-3 + R(3) + R(2) * q + q**2}
return self.element_class(self, elt)

def some_elements(self):
Expand Down Expand Up @@ -450,13 +449,7 @@ def casimir_element(self):
"""
q = self._q
I = self._indices
d = {I((1, 1, 1, 0, 0, 0)): q, # q ABC
I((2, 0, 0, 0, 0, 0)): q**2, # q^2 A^2
I((0, 2, 0, 0, 0, 0)): q**-2, # q^-2 B^2
I((0, 0, 2, 0, 0, 0)): q**2, # q^2 C^2
I((1, 0, 0, 1, 0, 0)): -q, # -q A\alpha
I((0, 1, 0, 0, 1, 0)): -q**-1, # -q^-1 B\beta
I((0, 0, 1, 0, 0, 1)): -q} # -q C\gamma
d = {I((1, 1, 1, 0, 0, 0)): q, I((2, 0, 0, 0, 0, 0)): q**2, I((0, 2, 0, 0, 0, 0)): q**-2, I((0, 0, 2, 0, 0, 0)): q**2, I((1, 0, 0, 1, 0, 0)): -q, I((0, 1, 0, 0, 1, 0)): -(q**-1), I((0, 0, 1, 0, 0, 1)): -q} # q ABC # q^2 A^2 # q^-2 B^2 # q^2 C^2 # -q A\alpha # -q^-1 B\beta # -q C\gamma
return self.element_class(self, d)

@cached_method
Expand Down Expand Up @@ -518,19 +511,15 @@ def product_on_basis(self, x, y):
if rhs[0] > 0: # rhs has an A to commute with C
lhs[2] -= 1
rhs[0] -= 1
rel = {I((1, 0, 1, 0, 0, 0)): q**-2, # q^2 AC
I((0, 1, 0, 0, 0, 0)): q**-3 - q**1, # q^-1(q^-2-q^2) B
I((0, 0, 0, 0, 1, 0)): 1 - q**-2} # -q^-1(q^-1-q) b
rel = {I((1, 0, 1, 0, 0, 0)): q**-2, I((0, 1, 0, 0, 0, 0)): q**-3 - q**1, I((0, 0, 0, 0, 1, 0)): 1 - q**-2} # q^2 AC # q^-1(q^-2-q^2) B # -q^-1(q^-1-q) b
rel = self.element_class(self, rel)
return self.monomial(I(lhs+[0]*3)) * (rel * self.monomial(I(rhs)))
return self.monomial(I(lhs + [0] * 3)) * (rel * self.monomial(I(rhs)))
if rhs[1] > 0: # rhs has a B to commute with C
lhs[2] -= 1
rhs[1] -= 1
rel = {I((0, 1, 1, 0, 0, 0)): q**2, # q^2 BC
I((1, 0, 0, 0, 0, 0)): q**3 - q**-1, # q(q^2-q^-2) A
I((0, 0, 0, 1, 0, 0)): -q**2 + 1} # -q(q-q^-1) a
rel = {I((0, 1, 1, 0, 0, 0)): q**2, I((1, 0, 0, 0, 0, 0)): q**3 - q**-1, I((0, 0, 0, 1, 0, 0)): -(q**2) + 1} # q^2 BC # q(q^2-q^-2) A # -q(q-q^-1) a
rel = self.element_class(self, rel)
return self.monomial(I(lhs+[0]*3)) * (rel * self.monomial(I(rhs)))
return self.monomial(I(lhs + [0] * 3)) * (rel * self.monomial(I(rhs)))
# nothing to commute as rhs has no A nor B
rhs[2] += lhs[2]
rhs[1] = lhs[1]
Expand All @@ -541,11 +530,9 @@ def product_on_basis(self, x, y):
if rhs[0] > 0: # rhs has an A to commute with B
lhs[1] -= 1
rhs[0] -= 1
rel = {I((1, 1, 0, 0, 0, 0)): q**2, # q^2 AB
I((0, 0, 1, 0, 0, 0)): q**3 - q**-1, # q(q^2-q^-2) C
I((0, 0, 0, 0, 0, 1)): -q**2 + 1} # -q(q-q^-1) g
rel = {I((1, 1, 0, 0, 0, 0)): q**2, I((0, 0, 1, 0, 0, 0)): q**3 - q**-1, I((0, 0, 0, 0, 0, 1)): -(q**2) + 1} # q^2 AB # q(q^2-q^-2) C # -q(q-q^-1) g
rel = self.element_class(self, rel)
return self.monomial(I(lhs+[0]*3)) * (rel * self.monomial(I(rhs)))
return self.monomial(I(lhs + [0] * 3)) * (rel * self.monomial(I(rhs)))
# nothing to commute as rhs has no A
rhs[1] += lhs[1]
rhs[0] = lhs[0]
Expand Down Expand Up @@ -590,8 +577,8 @@ def permutation_automorphism(self):
sage: r3(AW.an_element()) == AW.an_element()
True
"""
A,B,C,a,b,g = self.gens()
return AlgebraMorphism(self, [B,C,A,b,g,a], codomain=self)
A, B, C, a, b, g = self.gens()
return AlgebraMorphism(self, [B, C, A, b, g, a], codomain=self)

rho = permutation_automorphism

Expand Down Expand Up @@ -637,11 +624,11 @@ def reflection_automorphism(self):
sage: s2(AW.an_element()) == AW.an_element()
True
"""
A,B,C,a,b,g = self.gens()
A, B, C, a, b, g = self.gens()
q = self._q
# Note that sage: (A*B-B*A) / (q-q^-1) == -q*A*B - (1+q^2)*C + q*g
Cp = C - q*A*B - (1+q**2)*C + q*g
return AlgebraMorphism(self, [B,A,Cp,b,a,g], codomain=self)
Cp = C - q * A * B - (1 + q**2) * C + q * g
return AlgebraMorphism(self, [B, A, Cp, b, a, g], codomain=self)

sigma = reflection_automorphism

Expand Down Expand Up @@ -745,26 +732,25 @@ def loop_representation(self):
True
"""
from sage.matrix.matrix_space import MatrixSpace

q = self._q
base = LaurentPolynomialRing(self.base_ring().fraction_field(), 'lambda')
la = base.gen()
inv = ~la
M = MatrixSpace(base, 2)
A = M([[la,1-inv],[0,inv]])
Ai = M([[inv,inv-1],[0,la]])
B = M([[inv,0],[la-1,la]])
Bi = M([[la,0],[1-la,inv]])
C = M([[1,1-la],[inv-1,la+inv-1]])
Ci = M([[la+inv-1,la-1],[1-inv,1]])
A = M([[la, 1 - inv], [0, inv]])
Ai = M([[inv, inv - 1], [0, la]])
B = M([[inv, 0], [la - 1, la]])
Bi = M([[la, 0], [1 - la, inv]])
C = M([[1, 1 - la], [inv - 1, la + inv - 1]])
Ci = M([[la + inv - 1, la - 1], [1 - inv, 1]])
mu = la + inv
nu = (self._q**2 + self._q**-2) * mu + mu**2
nuI = M(nu)
# After #29374 is fixed, the category can become
# Algebras(Rings().Commutative()) as it was before #29399.
category = Rings()
return AlgebraMorphism(self, [q*A + q**-1*Ai, q*B + q**-1*Bi, q*C + q**-1*Ci,
nuI, nuI, nuI],
codomain=M, category=category)
return AlgebraMorphism(self, [q * A + q**-1 * Ai, q * B + q**-1 * Bi, q * C + q**-1 * Ci, nuI, nuI, nuI], codomain=M, category=category)

pi = loop_representation

Expand All @@ -789,8 +775,8 @@ class AlgebraMorphism(ModuleMorphismByLinearity):
An algebra morphism of the Askey-Wilson algebra defined by
the images of the generators.
"""
def __init__(self, domain, on_generators, position=0, codomain=None,
category=None):

def __init__(self, domain, on_generators, position=0, codomain=None, category=None):
"""
Given a map on the multiplicative basis of a free algebra, this method
returns the algebra morphism that is the linear extension of its image
Expand All @@ -816,8 +802,7 @@ def __init__(self, domain, on_generators, position=0, codomain=None,
if category is None:
category = Algebras(Rings().Commutative()).WithBasis()
self._on_generators = tuple(on_generators)
ModuleMorphismByLinearity.__init__(self, domain=domain, codomain=codomain,
position=position, category=category)
ModuleMorphismByLinearity.__init__(self, domain=domain, codomain=codomain, position=position, category=category)

def __eq__(self, other):
"""
Expand All @@ -835,12 +820,7 @@ def __eq__(self, other):
sage: id == rho * rho * rho
True
"""
return (self.__class__ is other.__class__ and self.parent() == other.parent()
and self._zero == other._zero
and self._on_generators == other._on_generators
and self._position == other._position
and self._is_module_with_basis_over_same_base_ring
== other._is_module_with_basis_over_same_base_ring)
return self.__class__ is other.__class__ and self.parent() == other.parent() and self._zero == other._zero and self._on_generators == other._on_generators and self._position == other._position and self._is_module_with_basis_over_same_base_ring == other._is_module_with_basis_over_same_base_ring

def _on_basis(self, c):
r"""
Expand Down Expand Up @@ -903,8 +883,7 @@ def _on_basis(self, c):
3*q^2*A*B*g - q*A*B - (3*q^-1-3*q^3)*C*g
+ (3-3*q^2)*g^2 - q^2*C + q*g
"""
return self.codomain().prod(self._on_generators[i]**exp
for i, exp in enumerate(c))
return self.codomain().prod(self._on_generators[i] ** exp for i, exp in enumerate(c))

def _composition_(self, right, homset):
"""
Expand All @@ -927,7 +906,5 @@ def _composition_(self, right, homset):
"""
if isinstance(right, AlgebraMorphism):
cat = homset.homset_category()
return AlgebraMorphism(homset.domain(),
[right(g) for g in self._on_generators],
codomain=homset.codomain(), category=cat)
return AlgebraMorphism(homset.domain(), [right(g) for g in self._on_generators], codomain=homset.codomain(), category=cat)
return super()._composition_(right, homset)
10 changes: 5 additions & 5 deletions src/sage/algebras/associated_graded.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class AssociatedGradedAlgebra(CombinatorialFreeModule):

- :wikipedia:`Filtered_algebra#Associated_graded_algebra`
"""

def __init__(self, A, category=None):
"""
Initialize ``self``.
Expand All @@ -188,8 +189,7 @@ def __init__(self, A, category=None):
except AttributeError:
opts = {'prefix': 'Abar'}

CombinatorialFreeModule.__init__(self, base_ring, A.basis().keys(),
category=category, **opts)
CombinatorialFreeModule.__init__(self, base_ring, A.basis().keys(), category=category, **opts)

# Setup the conversion back
phi = self.module_morphism(diagonal=lambda x: base_one, codomain=A)
Expand All @@ -208,6 +208,7 @@ def _repr_(self) -> str:
with cross product over Rational Field
"""
from sage.categories.algebras_with_basis import AlgebrasWithBasis

if self in AlgebrasWithBasis:
return "Graded Algebra of {}".format(self._A)
return "Graded Module of {}".format(self._A)
Expand All @@ -223,6 +224,7 @@ def _latex_(self) -> str:
\operatorname{gr} ...
"""
from sage.misc.latex import latex

return "\\operatorname{gr} " + latex(self._A)

def _element_constructor_(self, x):
Expand Down Expand Up @@ -338,6 +340,4 @@ def product_on_basis(self, x, y):
"""
ret = self._A.product_on_basis(x, y)
deg = self._A.degree_on_basis(x) + self._A.degree_on_basis(y)
return self.sum_of_terms([(i,c) for i,c in ret
if self._A.degree_on_basis(i) == deg],
distinct=True)
return self.sum_of_terms([(i, c) for i, c in ret if self._A.degree_on_basis(i) == deg], distinct=True)
10 changes: 4 additions & 6 deletions src/sage/algebras/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
"""

from sage.misc.lazy_import import lazy_import

lazy_import('sage.algebras.free_algebra', 'FreeAlgebra', as_='Free')
lazy_import('sage.algebras.quatalg.quaternion_algebra', 'QuaternionAlgebra', as_='Quaternion')
lazy_import('sage.algebras.steenrod.steenrod_algebra', 'SteenrodAlgebra', as_='Steenrod')
lazy_import('sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra',
'FiniteDimensionalAlgebra', as_='FiniteDimensional')
lazy_import('sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra', 'FiniteDimensionalAlgebra', as_='FiniteDimensional')
lazy_import('sage.algebras.group_algebra', 'GroupAlgebra', as_='Group')
lazy_import('sage.algebras.clifford_algebra', 'CliffordAlgebra', as_='Clifford')
lazy_import('sage.algebras.clifford_algebra', 'ExteriorAlgebra', as_='Exterior')
Expand Down Expand Up @@ -131,15 +131,13 @@
lazy_import('sage.combinat.grossman_larson_algebras', 'GrossmanLarsonAlgebra', 'GrossmanLarson')
lazy_import('sage.algebras.quantum_clifford', 'QuantumCliffordAlgebra', 'QuantumClifford')
lazy_import('sage.algebras.quantum_oscillator', 'QuantumOscillatorAlgebra', 'QuantumOscillator')
lazy_import('sage.algebras.quantum_matrix_coordinate_algebra',
'QuantumMatrixCoordinateAlgebra', 'QuantumMatrixCoordinate')
lazy_import('sage.algebras.quantum_matrix_coordinate_algebra', 'QuantumMatrixCoordinateAlgebra', 'QuantumMatrixCoordinate')
lazy_import('sage.algebras.quantum_matrix_coordinate_algebra', 'QuantumGL')
lazy_import('sage.algebras.q_commuting_polynomials', 'qCommutingPolynomials')
lazy_import('sage.algebras.q_commuting_polynomials', 'qCommutingLaurentPolynomials')
lazy_import('sage.algebras.tensor_algebra', 'TensorAlgebra', 'Tensor')
lazy_import('sage.algebras.quantum_groups.quantum_group_gap', 'QuantumGroup')
lazy_import('sage.algebras.quantum_groups.ace_quantum_onsager',
'ACEQuantumOnsagerAlgebra', 'AlternatingCentralExtensionQuantumOnsager')
lazy_import('sage.algebras.quantum_groups.ace_quantum_onsager', 'ACEQuantumOnsagerAlgebra', 'AlternatingCentralExtensionQuantumOnsager')
lazy_import('sage.algebras.down_up_algebra', 'DownUpAlgebra', 'DownUp')
lazy_import('sage.algebras.yangian', 'Yangian')
lazy_import('sage.algebras.octonion_algebra', 'OctonionAlgebra', 'Octonion')
Expand Down
Loading
Loading