Skip to content

Commit 1eb2b9a

Browse files
author
Release Manager
committed
gh-40819: various details in algebras, categories after some suggestions by `ruff` ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40819 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents d546825 + 47848b4 commit 1eb2b9a

File tree

10 files changed

+18
-29
lines changed

10 files changed

+18
-29
lines changed

src/sage/algebras/lie_algebras/quotient.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from sage.categories.homset import Hom
2222
from sage.categories.lie_algebras import LieAlgebras
2323
from sage.categories.morphism import SetMorphism
24-
from sage.structure.element import Element
2524
from sage.structure.indexed_generators import standardize_names_index_set
2625

2726

@@ -218,7 +217,6 @@ def __classcall_private__(cls, ambient, I, names=None, index_set=None,
218217

219218
# extract an index set from a complementary basis to the ideal
220219
I_supp = [X.leading_support() for X in I.leading_monomials()]
221-
inv = ambient.basis().inverse_family()
222220
IA = I.ambient()
223221
B = ambient.basis()
224222
if index_set_mapping is None:
@@ -264,7 +262,6 @@ def __init__(self, L, I, names, index_set, index_set_mapping, category=None):
264262
sage: TestSuite(K).run()
265263
"""
266264
B = L.basis()
267-
IA = I.ambient()
268265
self._index_set_mapping = dict(index_set_mapping)
269266
sm = L.module().submodule_with_basis([I.reduce(B[k]).to_vector()
270267
for k in self._index_set_mapping.values()])

src/sage/categories/coxeter_groups.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,10 +1924,10 @@ def reduced_word_graph(self):
19241924

19251925
P = self.parent()
19261926
edges = []
1927-
for i, x in enumerate(R):
1928-
x = tuple(x)
1929-
for y in R[i:]:
1930-
y = tuple(y)
1927+
for i, _x in enumerate(R):
1928+
x = tuple(_x)
1929+
for _y in R[i:]:
1930+
y = tuple(_y)
19311931
# Check that the reduced expressions differ by only
19321932
# a single braid move
19331933
j = 0

src/sage/categories/crystals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ def direct_sum(self, X):
12501250
__add__ = direct_sum
12511251

12521252
@abstract_method(optional=True)
1253-
def connected_components_generators(self):
1253+
def connected_components_generators(self) -> tuple:
12541254
"""
12551255
Return a tuple of generators for each of the connected components
12561256
of ``self``.

src/sage/categories/finite_dimensional_lie_algebras_with_basis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ def ideal(self, *gens, **kwds):
10751075
[x, y]
10761076
"""
10771077
from sage.algebras.lie_algebras.subalgebra import LieSubalgebra_finite_dimensional_with_basis
1078-
from sage.structure.element import parent, Element
1078+
from sage.structure.element import Element
10791079
if len(gens) == 1 and not isinstance(gens[0], Element):
10801080
gens = gens[0]
10811081
category = kwds.pop('category', None)
@@ -2720,17 +2720,17 @@ def reduce(self, X):
27202720
P = X.parent()
27212721
X = self.ambient()(X) # make sure it is in the ambient space
27222722
for Y in self.basis():
2723-
Y = self.lift(Y)
2724-
k, c = Y.leading_item(key=self._order)
2723+
lY = self.lift(Y)
2724+
k, c = lY.leading_item(key=self._order)
27252725
if not X[k]: # scalar will be 0
27262726
continue
27272727

27282728
if is_field:
2729-
X -= (X[k] / c) * Y
2729+
X -= (X[k] / c) * lY
27302730
else:
27312731
try:
27322732
q, _ = X[k].quo_rem(c)
2733-
X -= q * Y
2733+
X -= q * lY
27342734
except AttributeError:
27352735
break
27362736

src/sage/categories/finite_lattice_posets.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# *****************************************************************************
1111

1212
from sage.categories.category_with_axiom import CategoryWithAxiom
13-
from sage.misc.cachefunc import cached_method
1413

1514

1615
class FiniteLatticePosets(CategoryWithAxiom):

src/sage/categories/highest_weight_crystals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def additional_structure(self):
114114
class ParentMethods:
115115

116116
@cached_method
117-
def highest_weight_vectors(self):
117+
def highest_weight_vectors(self) -> tuple:
118118
r"""
119119
Return the highest weight vectors of ``self``.
120120
@@ -674,7 +674,7 @@ class ParentMethods:
674674
Implement operations on tensor products of crystals.
675675
"""
676676
@cached_method
677-
def highest_weight_vectors(self):
677+
def highest_weight_vectors(self) -> tuple:
678678
r"""
679679
Return the highest weight vectors of ``self``.
680680

src/sage/categories/ore_modules.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
from sage.misc.lazy_attribute import lazy_attribute
2-
31
from sage.categories.modules import Modules
42
from sage.categories.category_types import Category_over_base_ring
5-
from sage.categories.homsets import Homsets
63
from sage.rings.polynomial.ore_polynomial_ring import OrePolynomialRing
74

85

src/sage/categories/pushout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ def _apply_functor(self, R):
19551955
return FreeModule(R, self.n, sparse=self.is_sparse, inner_product_matrix=self.inner_product_matrix,
19561956
with_basis=self.with_basis, basis_keys=self.basis_keys)
19571957
return FreeModule(R, self.n, sparse=self.is_sparse, inner_product_matrix=self.inner_product_matrix,
1958-
with_basis=self.with_basis, basis_keys=self.basis_keys, name=name, latex_name=latex_name)
1958+
with_basis=self.with_basis, basis_keys=self.basis_keys, name=name, latex_name=latex_name)
19591959

19601960
def _apply_functor_to_morphism(self, f):
19611961
"""

src/sage/categories/rings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
from sage.misc.prandom import randint
2121
from sage.categories.category_with_axiom import CategoryWithAxiom
2222
from sage.categories.rngs import Rngs
23-
from sage.structure.element import Element
24-
from sage.structure.parent import Parent
2523

2624

2725
class Rings(CategoryWithAxiom):

src/sage/categories/supercrystals.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def genuine_highest_weight_vectors(self):
146146

147147
connected_components_generators = genuine_highest_weight_vectors
148148

149-
def connected_components(self):
149+
def connected_components(self) -> list:
150150
r"""
151151
Return the connected components of ``self`` as subcrystals.
152152
@@ -174,17 +174,15 @@ def connected_components(self):
174174
CCs = []
175175

176176
for mg in self.connected_components_generators():
177-
if not isinstance(mg, tuple):
178-
mg = (mg,)
179-
subcrystal = self.subcrystal(generators=mg,
177+
subcrystal = self.subcrystal(generators=(mg,),
180178
index_set=index_set,
181179
cartan_type=cartan_type,
182180
category=category)
183181
CCs.append(subcrystal)
184182

185183
return CCs
186184

187-
def genuine_lowest_weight_vectors(self):
185+
def genuine_lowest_weight_vectors(self) -> tuple:
188186
r"""
189187
Return the tuple of genuine lowest weight elements of ``self``.
190188
@@ -205,7 +203,7 @@ def genuine_lowest_weight_vectors(self):
205203
return tuple([x[1] for x in self._genuine_highest_lowest_weight_vectors()])
206204

207205
@cached_method
208-
def _genuine_highest_lowest_weight_vectors(self):
206+
def _genuine_highest_lowest_weight_vectors(self) -> tuple:
209207
r"""
210208
Return the genuine lowest and highest weight elements of ``self``.
211209
@@ -267,7 +265,7 @@ def character(self):
267265
return A.sum(A(x.weight()) for x in self)
268266

269267
@cached_method
270-
def highest_weight_vectors(self):
268+
def highest_weight_vectors(self) -> tuple:
271269
"""
272270
Return the highest weight vectors of ``self``.
273271

0 commit comments

Comments
 (0)