Skip to content

Commit

Permalink
Trac #33732: get rid of unused variables in algebra
Browse files Browse the repository at this point in the history
found using pylint W0612

URL: https://trac.sagemath.org/33732
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed May 22, 2022
2 parents 1753073 + 7750e08 commit 18b7c88
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/sage/algebras/free_algebra_element.py
Expand Up @@ -246,9 +246,9 @@ def variables(self):
sage: elt.variables()
[x, y, z]
"""
v = set([])
for s in self._monomial_coefficients: # Only gets the keys
for var,exp in s:
v = set()
for s in self._monomial_coefficients: # Only gets the keys
for var, _ in s:
v.add(var)
A = self.parent()
return sorted(map(A, v))
Expand Down
7 changes: 4 additions & 3 deletions src/sage/algebras/free_algebra_quotient_element.py
Expand Up @@ -240,11 +240,12 @@ def _mul_(self, y):
-5459/25 + 40*i - 12*j + 340*k
"""
A = self.parent()
def monomial_product(X,w,m):

def monomial_product(X, w, m):
mats = X._FreeAlgebraQuotient__matrix_action
for (j,k) in m._element_list:
for j, k in m._element_list:
M = mats[int(j)]
for l in range(k):
for _ in range(k):
w *= M
return w
u = self.__vector.__copy__()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/algebras/lie_algebras/classical_lie_algebra.py
Expand Up @@ -295,7 +295,7 @@ def highest_root_basis_elt(self, pos=True):
gens = self._f
cur = gens[i]
for j in reversed(w):
for k in range(-r.scalar(coroots[j])):
for _ in range(-r.scalar(coroots[j])):
cur = self.bracket(gens[j], cur)
r = r.reflection(coroots[j], True)
return cur
Expand Down Expand Up @@ -1724,9 +1724,9 @@ def _test_structure_coeffs(self, **options):
# Setup the GAP objects
from sage.libs.gap.libgap import libgap
L = libgap.SimpleLieAlgebra(ct.letter, ct.n, libgap(self.base_ring()))
pos_B, neg_B, h_B = libgap.ChevalleyBasis(L)
pos_B, neg_B, _ = libgap.ChevalleyBasis(L)
gap_p_roots = libgap.PositiveRoots(libgap.RootSystem(L)).sage()
#E, F, H = libgap.CanonicalGenerators(L)
# E, F, H = libgap.CanonicalGenerators(L)

# Setup the conversion between the Sage roots and GAP roots.
# The GAP roots are given in terms of the weight lattice.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/lie_algebras/subalgebra.py
Expand Up @@ -916,7 +916,7 @@ def reduce(self, X):
X = X - X[k] / c * Y
else:
try:
q, r = X[k].quo_rem(c)
q, _ = X[k].quo_rem(c)
X = X - q * Y
except AttributeError:
pass
Expand Down
8 changes: 4 additions & 4 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Expand Up @@ -798,7 +798,7 @@ def maximal_order(self, take_shortcuts=True):
e_new_gens = []

# For each prime at which R is not yet maximal, make it bigger
for (p, p_val) in d_R.factor():
for p, _ in d_R.factor():
e = R.basis()
while self.quaternion_order(e).discriminant().valuation(p) > d_A.valuation(p):
# Compute a normalized basis at p
Expand Down Expand Up @@ -1221,7 +1221,7 @@ def modp_splitting_data(self, p):
if self.discriminant() % p == 0:
raise ValueError("p (=%s) must be an unramified prime" % p)

i, j, k = self.gens()
i, j, _ = self.gens()
F = GF(p)
i2 = F(i * i)
j2 = F(j * j)
Expand All @@ -1230,7 +1230,7 @@ def modp_splitting_data(self, p):
I = M([0, i2, 1, 0])
if i2 == 0:
raise NotImplementedError("algorithm for computing local splittings not implemented in general (currently require the first invariant to be coprime to p)")
i2inv = 1/i2
i2inv = ~i2
a = None
for b in list(F):
if not b:
Expand Down Expand Up @@ -2865,7 +2865,7 @@ def cyclic_right_subideals(self, p, alpha=None):
else:
x = alpha
lines = []
for i in range(p+1):
for _ in range(p + 1):
lines.append(P1.normalize(x[0, 0], x[0, 1]))
x *= alpha

Expand Down
4 changes: 2 additions & 2 deletions src/sage/algebras/splitting_algebra.py
Expand Up @@ -283,8 +283,8 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True):
root_names_reduces.remove(root_name)

P = base_ring_step[root_names_reduces[0]]
p = P(monic_polynomial.dict())
q, r = p.quo_rem( (P.gen()-first_root) )
p = P(monic_polynomial.dict())
q, _ = p.quo_rem((P.gen() - first_root))

verbose("Invoking recursion with: %s" % (q,))

Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/steenrod/steenrod_algebra_bases.py
Expand Up @@ -1074,7 +1074,7 @@ def sorting_pair(s,t,basis): # pair used for sorting the basis
okay = False
break

for ((s,t), exp) in p_mono:
for ((s, t), _) in p_mono:
if ((len(profile[0]) > t-1 and profile[0][t-1] <= s)
or (len(profile[0]) <= t-1 and trunc < Infinity)):
okay = False
Expand Down
4 changes: 2 additions & 2 deletions src/sage/algebras/weyl_algebra.py
Expand Up @@ -403,8 +403,8 @@ def _mul_(self, other):
for mr in other.__monomials:
cr = other.__monomials[mr]
cur = [ ((mr[0], t), cl * cr) ]
for i,p in enumerate(ml[1]):
for j in range(p):
for i, p in enumerate(ml[1]):
for _ in range(p):
next = []
for m, c in cur: # Distribute and apply the derivative
diff = list(m[1])
Expand Down
10 changes: 5 additions & 5 deletions src/sage/algebras/yangian.py
Expand Up @@ -654,12 +654,12 @@ def product_on_basis(self, x, y):
return self.monomial(x * y)

# The computation is done on generators, so apply generators one at
# a time until all have been applied
# a time until all have been applied
if len(x) != 1:
I = self._indices
cur = self.monomial(y)
for gen,exp in reversed(x._sorted_items()):
for i in range(exp):
for gen, exp in reversed(x._sorted_items()):
for _ in range(exp):
cur = self.monomial(I.gen(gen)) * cur
return cur

Expand All @@ -670,8 +670,8 @@ def product_on_basis(self, x, y):
# Otherwise we need to commute it along
I = self._indices
cur = self.monomial(x)
for gen,exp in y._sorted_items():
for i in range(exp):
for gen, exp in y._sorted_items():
for _ in range(exp):
cur = cur * self.monomial(I.gen(gen))
return cur

Expand Down

0 comments on commit 18b7c88

Please sign in to comment.