Skip to content

Commit da8e56d

Browse files
author
Release Manager
committed
gh-35318: fix E502 in schemes and combinat <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> ### 📚 Description fix pycodestyle E502 warning in schemes/ and combinat/ <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If it resolves an open issue, please link to the issue here. For example "Closes #1337" --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have made sure that the title is self-explanatory and the description concisely explains the PR. - [ ] I have linked an issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open pull requests that this PR logically depends on --> <!-- - #xyz: short description why this is a dependency - #abc: ... --> URL: #35318 Reported by: Frédéric Chapoton Reviewer(s): Frédéric Chapoton, Kwankyu Lee
2 parents 46e46a1 + 0ee39ac commit da8e56d

26 files changed

+207
-197
lines changed

src/sage/combinat/designs/difference_family.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ def radical_difference_set(K, k, l=1, existence=False, check=True):
591591
x = K.multiplicative_generator()
592592
D = K.cyclotomic_cosets(x**((v-1)//k), [K.one()])
593593
if is_difference_family(K, D, v, k, l):
594-
print("** You found a new example of radical difference set **\n"\
595-
"** for the parameters (v,k,l)=({},{},{}). **\n"\
594+
print("** You found a new example of radical difference set **\n"
595+
"** for the parameters (v,k,l)=({},{},{}). **\n"
596596
"** Please contact [email protected] **\n".format(v, k, l))
597597
if existence:
598598
return True
@@ -602,8 +602,8 @@ def radical_difference_set(K, k, l=1, existence=False, check=True):
602602
D = K.cyclotomic_cosets(x**((v-1)//(k-1)), [K.one()])
603603
D[0].insert(0,K.zero())
604604
if is_difference_family(K, D, v, k, l):
605-
print("** You found a new example of radical difference set **\n"\
606-
"** for the parameters (v,k,l)=({},{},{}). **\n"\
605+
print("** You found a new example of radical difference set **\n"
606+
"** for the parameters (v,k,l)=({},{},{}). **\n"
607607
"** Please contact [email protected] **\n".format(v, k, l))
608608
if existence:
609609
return True

src/sage/combinat/finite_state_machine_generators.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def Word(self, word, input_alphabet=None):
276276
letters = list(word)
277277
length = len(letters)
278278
from sage.rings.integer_ring import ZZ
279-
return Automaton([(ZZ(i), ZZ(i+1), letter)
279+
return Automaton([(ZZ(i), ZZ(i + 1), letter)
280280
for i, letter in enumerate(letters)],
281281
initial_states=[ZZ(0)],
282282
final_states=[ZZ(length)],
@@ -1241,7 +1241,7 @@ def convert_output(output):
12411241
for ring in output_rings:
12421242
try:
12431243
return ring(output)
1244-
except (ValueError,TypeError):
1244+
except (ValueError, TypeError):
12451245
pass
12461246
return output
12471247

@@ -1353,12 +1353,12 @@ def to_list(output):
13531353
assert equation == parsed_equation, \
13541354
"Parsing of %s failed for unknown reasons." % (equation,)
13551355

1356-
rule = self.RecursionRule(K=K,r=r, k=k, s=s, t=to_list(t))
1356+
rule = self.RecursionRule(K=K, r=r, k=k, s=s, t=to_list(t))
13571357
return rule
13581358

13591359
def Recursion(self, recursions, base, function=None, var=None,
13601360
input_alphabet=None, word_function=None,
1361-
is_zero=None, output_rings=[ZZ, QQ]):
1361+
is_zero=None, output_rings=[ZZ, QQ]):
13621362
r"""
13631363
Return a transducer realizing the given recursion when reading
13641364
the digit expansion with base ``base``.
@@ -1815,11 +1815,11 @@ def Recursion(self, recursions, base, function=None, var=None,
18151815

18161816
for given_rule in rules:
18171817
q, remainder = given_rule.r.quo_rem(base**given_rule.K)
1818-
rule=self.RecursionRule(K=given_rule.K,
1819-
r=remainder,
1820-
k=given_rule.k,
1821-
s=given_rule.s - base**given_rule.k*q,
1822-
t=given_rule.t)
1818+
rule = self.RecursionRule(K=given_rule.K,
1819+
r=remainder,
1820+
k=given_rule.k,
1821+
s=given_rule.s - base**given_rule.k * q,
1822+
t=given_rule.t)
18231823
for m in range(max_K - rule.K + 1):
18241824
for ell in range(base**m):
18251825
R = rule.r + base**rule.K * ell
@@ -1988,9 +1988,8 @@ def f(n):
19881988
"Too many initial conditions, only give one of %s." %
19891989
cycle[1:])
19901990
required_initial_values.update(intersection)
1991-
output_sum = sum([edge[2]
1992-
for edge in recursion_digraph.\
1993-
outgoing_edge_iterator(cycle[1:])],
1991+
output_sum = sum([e[2]
1992+
for e in recursion_digraph.outgoing_edge_iterator(cycle[1:])],
19941993
[])
19951994
if not is_zero(output_sum):
19961995
raise ValueError(

src/sage/combinat/gelfand_tsetlin_patterns.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ def _row_iter(self, upper_row):
993993
[2, 0]
994994
[2, 1]
995995
"""
996-
row = [x-1 for x in upper_row[1:]]
996+
row = [x - 1 for x in upper_row[1:]]
997997
row_len = len(row)
998998
pos = 0
999999
while pos >= 0:
@@ -1002,11 +1002,11 @@ def _row_iter(self, upper_row):
10021002
pos -= 1
10031003
continue
10041004
# If it would create an invalid entry, backstep
1005-
if ( pos > 0 and (row[pos] >= row[pos-1] \
1006-
or (self._strict and row[pos] == row[pos-1]-1)) ) \
1005+
if (pos > 0 and (row[pos] >= row[pos - 1]
1006+
or (self._strict and row[pos] == row[pos - 1] - 1))) \
10071007
or row[pos] >= upper_row[pos] \
10081008
or (self._k is not None and row[pos] >= self._k):
1009-
row[pos] = upper_row[pos+1] - 1
1009+
row[pos] = upper_row[pos + 1] - 1
10101010
pos -= 1
10111011
continue
10121012
row[pos] += 1

src/sage/combinat/integer_vector.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,10 @@ def cardinality(self):
14551455
return Integer(binomial(self.n + self.k - 1, self.n))
14561456
# do by inclusion / exclusion on the number
14571457
# i of parts greater than m
1458-
return Integer(sum( (-1)**i * binomial(self.n+self.k-1-i*(m+1), self.k-1) \
1459-
* binomial(self.k,i) for i in range(self.n/(m+1)+1) ))
1458+
n, k = self.n, self.k
1459+
return Integer(sum(
1460+
(-1)**i * binomial(n + k - 1 - i * (m + 1), k - 1)
1461+
* binomial(k, i) for i in range(self.n // (m + 1) + 1)))
14601462
return ZZ.sum(ZZ.one() for x in self)
14611463

14621464
def __iter__(self):

src/sage/combinat/multiset_partition_into_sets_ordered.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,8 +2787,8 @@ def _base_iterator(constraints):
27872787
if min_ord:
27882788
min_k = max(1, min_k, min_ord // len(A))
27892789
if infinity not in (max_k, max_ord):
2790-
return chain(*(_iterator_order(A, ord, range(min_k, max_k+1)) \
2791-
for ord in range(min_ord, max_ord+1)))
2790+
return chain(*(_iterator_order(A, ord, range(min_k, max_k + 1))
2791+
for ord in range(min_ord, max_ord + 1)))
27922792
# else
27932793
return None
27942794

src/sage/combinat/ncsf_qsym/generic_basis_code.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,9 @@ def skew(self, x, y, side='left'):
472472
x = self(x)
473473
y = self.dual()(y)
474474
v = 1 if side == 'left' else 0
475-
return self.sum(coeff * y[IJ[1-v]] * self[IJ[v]] \
476-
for (IJ, coeff) in x.coproduct() if IJ[1-v] in y.support())
475+
return self.sum(coeff * y[IJ[1-v]] * self[IJ[v]]
476+
for (IJ, coeff) in x.coproduct()
477+
if IJ[1-v] in y.support())
477478
else:
478479
return self._skew_by_coercion(x, y, side=side)
479480

@@ -710,9 +711,9 @@ def duality_pairing_matrix(self, basis, degree):
710711
# TODO: generalize to keys indexing the basis of the graded component
711712
from sage.combinat.composition import Compositions
712713
return matrix(self.base_ring(),
713-
[[self.duality_pairing(self[I], basis[J]) \
714-
for J in Compositions(degree)] \
715-
for I in Compositions(degree)])
714+
[[self.duality_pairing(self[I], basis[J])
715+
for J in Compositions(degree)]
716+
for I in Compositions(degree)])
716717

717718
def counit_on_basis(self, I):
718719
r"""

src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ def __init__(self, cartan_type, B):
320320
FullTensorProductOfRegularCrystals.__init__(self, tensor_prod, cartan_type=cartan_type)
321321
# This is needed to override the module_generators set in FullTensorProductOfRegularCrystals
322322
self.module_generators = HighestWeightTensorKRT(self)
323-
self.rename("Tensor product of Kirillov-Reshetikhin tableaux of type %s and factor(s) %s"%(\
324-
cartan_type, B))
323+
self.rename("Tensor product of Kirillov-Reshetikhin tableaux "
324+
f"of type {cartan_type} and factor(s) {B}")
325325

326326
def __iter__(self):
327327
"""
328-
Returns the iterator of ``self``.
328+
Return the iterator of ``self``.
329329
330330
EXAMPLES::
331331

src/sage/combinat/root_system/root_lattice_realizations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def simple_roots(self):
464464
@cached_method
465465
def alpha(self):
466466
r"""
467-
Returns the family `(\alpha_i)_{i\in I}` of the simple roots,
467+
Return the family `(\alpha_i)_{i\in I}` of the simple roots,
468468
with the extra feature that, for simple irreducible root
469469
systems, `\alpha_0` yields the opposite of the highest root.
470470
@@ -475,13 +475,12 @@ def alpha(self):
475475
alpha[1]
476476
sage: alpha[0]
477477
-alpha[1] - alpha[2]
478-
479478
"""
480479
if self.root_system.is_finite() and self.root_system.is_irreducible():
481-
return Family(self.index_set(), self.simple_root, \
482-
hidden_keys = [0], hidden_function = lambda i: - self.highest_root())
483-
else:
484-
return self.simple_roots()
480+
return Family(self.index_set(), self.simple_root,
481+
hidden_keys=[0],
482+
hidden_function=lambda i: - self.highest_root())
483+
return self.simple_roots()
485484

486485
@cached_method
487486
def basic_imaginary_roots(self):

src/sage/combinat/sf/sfa.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,19 +2090,20 @@ def _from_cache(self, element, cache_function, cache_dict, **subs_dict):
20902090
# needed for the old kschur functions - TCS
20912091
part = _Partitions(part)
20922092
for part2, c2 in cache_dict[sum(part)][part].items():
2093-
if hasattr(c2,'subs'): # c3 may be in the base ring
2094-
c3 = c*BR(c2.subs(**subs_dict))
2093+
if hasattr(c2, 'subs'): # c3 may be in the base ring
2094+
c3 = c * BR(c2.subs(**subs_dict))
20952095
else:
2096-
c3 = c*BR(c2)
2096+
c3 = c * BR(c2)
20972097
# c3 = c*c2
20982098
# if hasattr(c3,'subs'): # c3 may be in the base ring
20992099
# c3 = c3.subs(**subs_dict)
2100-
z_elt[ part2 ] = z_elt.get(part2, zero) + BR(c3)
2100+
z_elt[part2] = z_elt.get(part2, zero) + BR(c3)
21012101
return self._from_dict(z_elt)
21022102

2103-
def _invert_morphism(self, n, base_ring, self_to_other_cache, other_to_self_cache,\
2104-
to_other_function=None, to_self_function=None, \
2105-
upper_triangular=False, lower_triangular=False, \
2103+
def _invert_morphism(self, n, base_ring,
2104+
self_to_other_cache, other_to_self_cache,
2105+
to_other_function=None, to_self_function=None,
2106+
upper_triangular=False, lower_triangular=False,
21062107
ones_on_diagonal=False):
21072108
r"""
21082109
Compute the inverse of a morphism between ``self`` and ``other``
@@ -5979,8 +5980,9 @@ def character_to_frobenius_image(self, n):
59795980
2*s[2, 2, 1] + s[3, 1, 1] + 4*s[3, 2] + 3*s[4, 1] + 2*s[5]
59805981
"""
59815982
p = self.parent().symmetric_function_ring().p()
5982-
return self.parent()(p.sum(self.eval_at_permutation_roots(rho) \
5983-
*p(rho)/rho.centralizer_size() for rho in Partitions(n)))
5983+
return self.parent()(p.sum(self.eval_at_permutation_roots(rho)
5984+
* p(rho) / rho.centralizer_size()
5985+
for rho in Partitions(n)))
59845986

59855987
def principal_specialization(self, n=infinity, q=None):
59865988
r"""

src/sage/combinat/words/paths.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ def __eq__(self, other):
455455
sage: W1 == W3
456456
False
457457
"""
458-
return self is other or (type(self) == type(other) and \
459-
self.alphabet() == other.alphabet() and \
460-
self.vector_space() == other.vector_space() and \
461-
self.letters_to_steps() == other.letters_to_steps())
458+
return self is other or (type(self) == type(other) and
459+
self.alphabet() == other.alphabet() and
460+
self.vector_space() == other.vector_space() and
461+
self.letters_to_steps() == other.letters_to_steps())
462462

463463
def __ne__(self, other):
464464
r"""

0 commit comments

Comments
 (0)