Skip to content

Commit

Permalink
gh-35355: partial fix for E221 (to be continued)
Browse files Browse the repository at this point in the history
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

Partial fix for pycodestyle E221, done using autopep8.

E221 multiple spaces before operator

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35355
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Apr 4, 2023
2 parents ae417bb + c43a9f2 commit a493495
Show file tree
Hide file tree
Showing 81 changed files with 341 additions and 341 deletions.
2 changes: 1 addition & 1 deletion src/sage/algebras/rational_cherednik_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def algebra_generators(self):
sage: list(R.algebra_generators())
[a1, a2, s1, s2, ac1, ac2]
"""
keys = ['a'+str(i) for i in self._cartan_type.index_set()]
keys = ['a'+str(i) for i in self._cartan_type.index_set()]
keys += ['s'+str(i) for i in self._cartan_type.index_set()]
keys += ['ac'+str(i) for i in self._cartan_type.index_set()]

Expand Down
12 changes: 6 additions & 6 deletions src/sage/algebras/splitting_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True):
deg = monic_polynomial.degree()

from sage.structure.category_object import normalize_names
self._root_names = normalize_names(deg-1, names)
self._root_names = normalize_names(deg-1, names)
root_names = list(self._root_names)
verbose("Create splitting algebra to base ring %s and polynomial %s (%s %s)"
% (base_ring, monic_polynomial, iterate, warning))
Expand All @@ -238,8 +238,8 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True):
if deg < 1:
raise ValueError("the degree of the polynomial must positive")

self._splitting_roots = []
self._coefficients_list = []
self._splitting_roots = []
self._coefficients_list = []
self._invertible_elements = {}

if isinstance(base_ring, SplittingAlgebra):
Expand Down Expand Up @@ -289,12 +289,12 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True):

SplittingAlgebra.__init__(self, q, root_names_reduces, warning=False)

splitting_roots = base_ring_step._splitting_roots + self._splitting_roots
splitting_roots = base_ring_step._splitting_roots + self._splitting_roots
coefficients_list = base_ring_step._coefficients_list + self._coefficients_list

verbose("Adding roots: %s" % (splitting_roots))

self._splitting_roots = splitting_roots
self._splitting_roots = splitting_roots
self._coefficients_list = coefficients_list
else:
PolynomialQuotientRing_domain.__init__(self, P, p, root_name)
Expand Down Expand Up @@ -343,7 +343,7 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True):
# ------------------------------------------------------------------
if cf0_inv is not None:
deg_cf = len(cf)-1
pf = P(cf)
pf = P(cf)
for root in self._splitting_roots:
check = self(pf)
if not check.is_zero():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/algebra_functor.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def _apply_functor_to_morphism(self, f):
2*() + 2*(2,3) + (1,2,3) + 4*(1,3,2)
"""
from sage.categories.rings import Rings
domain = self(f.domain())
domain = self(f.domain())
codomain = self(f.codomain())
# we would want to use something like:
# domain.module_morphism(on_coefficients=h, codomain=codomain, category=Rings())
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/cartesian_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sage.categories.covariant_functorial_construction import CovariantFunctorialConstruction, CovariantConstructionCategory
from sage.categories.pushout import MultivariateConstructionFunctor

native_python_containers = set([tuple, list, set, frozenset, range])
native_python_containers = set([tuple, list, set, frozenset, range])

class CartesianProductFunctor(CovariantFunctorialConstruction, MultivariateConstructionFunctor):
"""
Expand Down
10 changes: 5 additions & 5 deletions src/sage/categories/category_with_axiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2609,11 +2609,11 @@ def super_categories(self):

class SubcategoryMethods:
FiniteDimensional = axiom("FiniteDimensional")
Commutative = axiom("Commutative")
Unital = axiom("Unital")
Connected = axiom("Connected")
Flying = axiom("Flying")
Blue = axiom("Blue")
Commutative = axiom("Commutative")
Unital = axiom("Unital")
Connected = axiom("Connected")
Flying = axiom("Flying")
Blue = axiom("Blue")

class FiniteDimensional(CategoryWithAxiom):
pass
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/covariant_functorial_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _base_category_class(cls):
"""
module_name = cls.__module__.replace(cls._functor_category.lower() + "_","")
import sys
name = cls.__name__.replace(cls._functor_category, "")
name = cls.__name__.replace(cls._functor_category, "")
__import__(module_name)
module = sys.modules[module_name]
return (module.__dict__[name],)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AdditiveCommutative(CategoryWithAxiom):
class AdditiveUnital(CategoryWithAxiom):
class Associative(CategoryWithAxiom):
AdditiveInverse = LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
Unital = LazyImport('sage.categories.semirings', 'Semirings', at_startup=True)
Unital = LazyImport('sage.categories.semirings', 'Semirings', at_startup=True)

class ParentMethods:

Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/enumerated_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __iter__(self):
"""
# Check if .first() and .next(x) are overridden in the subclass
if ( self.first != self._first_from_iterator and
self.next != self._next_from_iterator ):
self.next != self._next_from_iterator ):
return self._iterator_from_next()
#Check to see if .unrank() is overridden in the subclass
elif self.unrank != self._unrank_from_iterator:
Expand Down Expand Up @@ -592,7 +592,7 @@ def list(self):
[1, 2, 3]
"""
return list(self.tuple())
_list_default = list # needed by the check system.
_list_default = list # needed by the check system.

def _list_from_iterator(self):
r"""
Expand Down Expand Up @@ -1108,7 +1108,7 @@ def rank(self):
"""
return self.parent().rank(self)

Finite = LazyImport('sage.categories.finite_enumerated_sets', 'FiniteEnumeratedSets', at_startup=True)
Finite = LazyImport('sage.categories.finite_enumerated_sets', 'FiniteEnumeratedSets', at_startup=True)
Infinite = LazyImport('sage.categories.infinite_enumerated_sets', 'InfiniteEnumeratedSets', at_startup=True)

class CartesianProducts(CartesianProductsCategory):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/infinite_enumerated_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def list(self):
NotImplementedError: cannot list an infinite set
"""
raise NotImplementedError("cannot list an infinite set")
_list_default = list # needed by the check system.
_list_default = list # needed by the check system.

def _test_enumerated_set_iter_cardinality(self, **options):
"""
Expand Down
10 changes: 5 additions & 5 deletions src/sage/categories/quotient_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def xgcd(self, other):
return (P(g)/P(lcmD), P(s*selfD)/P(lcmD),P(t*otherD)/P(lcmD))
except (AttributeError, NotImplementedError, TypeError, ValueError):
zero = self.parent().zero()
one = self.parent().one()
one = self.parent().one()
if self != zero:
return (one, ~self, zero)
elif other != zero:
Expand Down Expand Up @@ -681,11 +681,11 @@ def _derivative(self, var=None):
try:
numder = num._derivative(var)
dender = den._derivative(var)
d = den.gcd(dender)
den = den // d
d = den.gcd(dender)
den = den // d
dender = dender // d
tnum = numder * den - num * dender
tden = self.denominator() * den
tnum = numder * den - num * dender
tden = self.denominator() * den
if not tden.is_one() and tden.is_unit():
try:
tnum = tnum * tden.inverse_of_unit()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/semigroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def cayley_graph(self, side="right", simple=False, elements=None,
generators = self.semigroup_generators()
if isinstance(generators, (list, tuple)):
generators = dict((self(g), self(g)) for g in generators)
left = (side == "left" or side == "twosided")
left = (side == "left" or side == "twosided")
right = (side == "right" or side == "twosided")

def add_edge(source, target, label, side_label):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/coding/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def transmit_unsafe(self, message):
zero = V.base_ring().zero()

errors = sample(range(n), number_errors + number_erasures)
error_positions = errors[:number_errors]
error_positions = errors[:number_errors]
erasure_positions = errors[number_errors:]

error_vector = random_error_vector(n, V.base_ring(), error_positions)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/coding/code_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def entropy_inverse(x, q=2):
if q < 2: # Here we check that q is actually at least 2
raise ValueError("The value q must be an integer greater than 1")

eps = 4.5e-16 # find_root has about this as the default xtol
eps = 4.5e-16 # find_root has about this as the default xtol
ymax = 1 - 1/q
if x <= eps:
return 0
Expand Down
12 changes: 6 additions & 6 deletions src/sage/coding/grs_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ def encode(self, p):
C = self.code()
if p.degree() >= C.dimension():
raise ValueError("The polynomial to encode must have degree at most %s" % (C.dimension() - 1))
alphas = C.evaluation_points()
alphas = C.evaluation_points()
col_mults = C.column_multipliers()
c = vector(C.base_ring(), [col_mults[i]*p(alphas[i]) for i in range(C.length())])
return c
Expand Down Expand Up @@ -1057,7 +1057,7 @@ def unencode_nocheck(self, c):
"""
C = self.code()
alphas = C.evaluation_points()
alphas = C.evaluation_points()
col_mults = C.column_multipliers()

c = [c[i]/col_mults[i] for i in range(C.length())]
Expand Down Expand Up @@ -1229,14 +1229,14 @@ def _decode_to_code_and_message(self, r):
r_list = copy(r)
r_list = [r[i]/col_mults[i] for i in range(0, C.length())]

t = (C.minimum_distance()-1) // 2
t = (C.minimum_distance()-1) // 2
l0 = n-1-t
l1 = n-1-t-(k-1)
S = matrix(C.base_field(), n, l0+l1+2,
S = matrix(C.base_field(), n, l0+l1+2,
lambda i, j: (C.evaluation_points()[i])**j if j<(l0+1)
else r_list[i]*(C.evaluation_points()[i])**(j-(l0+1)))
S = S.right_kernel()
S = S.basis_matrix().row(0)
S = S.right_kernel()
S = S.basis_matrix().row(0)
R = C.base_field()['x']

Q0 = R(S.list_from_positions(range(l0 + 1)))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/cluster_algebra_quiver/mutation_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def _connected_mutation_type(dg):
elif len( exc_labels ) == 1:
label = exc_labels[0]
v_out = label[0]
v_in = label[1]
v_in = label[1]
label = label[2]
if label == (1,-2):
if dict_in_out[ v_in ][0] == 1 and dict_in_out[ v_in ][1] == 0:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/crystals/generalized_young_walls.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def e(self, i):
"""
signature = self.generate_signature(i)
raw_signature = signature[0]
lastminus = signature[1].rfind('-')
lastminus = signature[1].rfind('-')
newdata = []
if lastminus > -1:
deletionrow = raw_signature[lastminus][1]
Expand Down Expand Up @@ -725,7 +725,7 @@ def in_highest_weight_crystal(self,La):
else:
p_not_found = True
for p in index_set:
if (j+k) % (n+1) == (p+1) % (n+1) and self.a(j,k) - self.a( (j-1) % (n+1) ,k) <= La.scalar(ac[p]):
if (j+k) % (n+1) == (p+1) % (n+1) and self.a(j,k) - self.a( (j-1) % (n+1) ,k) <= La.scalar(ac[p]):
p_not_found = False
continue
else:
Expand Down
10 changes: 5 additions & 5 deletions src/sage/combinat/designs/bibd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,15 +1372,15 @@ def BIBD_from_arc_in_desarguesian_projective_plane(n,k,existence=False):
from sage.libs.gap.libgap import libgap
from sage.matrix.constructor import Matrix

K = GF(q,'a')
K = GF(q,'a')
one = K.one()

# An irreducible quadratic form over K[X,Y]
GO = libgap.GeneralOrthogonalGroup(-1,2,q)
M = libgap.InvariantQuadraticForm(GO)['matrix']
M = Matrix(M)
M = M.change_ring(K)
Q = lambda xx,yy : M[0,0]*xx**2+(M[0,1]+M[1,0])*xx*yy+M[1,1]*yy**2
M = libgap.InvariantQuadraticForm(GO)['matrix']
M = Matrix(M)
M = M.change_ring(K)
Q = lambda xx,yy : M[0,0]*xx**2+(M[0,1]+M[1,0])*xx*yy+M[1,1]*yy**2

# Here, the additive subgroup H (of order n) of K mentioned in
# [Denniston69] is the set of all elements of K of degree < log_n
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/designs/block_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ def DesarguesianProjectivePlaneDesign(n, point_coordinates=True, check=True):
# we relabel the points with the integers from 0 to n^2 + n as follows:
# - the affine plane is the set of points [x:y:1] (i.e. the third coordinate
# is non-zero) and gets relabeled from 0 to n^2-1
affine_plane = lambda x,y: relabel[x] + n * relabel[y]
affine_plane = lambda x,y: relabel[x] + n * relabel[y]

# - the affine line is the set of points [x:1:0] (i.e. the third coordinate is
# zero but not the second one) and gets relabeled from n^2 to n^2 + n - 1
line_infinity = lambda x: n2 + relabel[x]
line_infinity = lambda x: n2 + relabel[x]

# - the point is [1:0:0] and gets relabeled n^2 + n
point_infinity = n2 + n
Expand Down Expand Up @@ -380,7 +380,7 @@ def DesarguesianProjectivePlaneDesign(n, point_coordinates=True, check=True):

if point_coordinates:
zero = K.zero()
one = K.one()
one = K.one()
d = {affine_plane(x,y): (x,y,one)
for x in Kiter
for y in Kiter}
Expand Down
40 changes: 20 additions & 20 deletions src/sage/combinat/designs/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def OA_8_69():
PBD = [[x for x in B if x not in oval] for B in BIBD]

sets_of_size_seven = [R for R in PBD if len(R) == 7]
others = [R for R in PBD if len(R) != 7]
others = [R for R in PBD if len(R) != 7]

# 68, 27, and 52 are the only elements appearing twice in the rows of
# sets_of_size_seven, and each row contains exactly one of them.
Expand Down Expand Up @@ -628,7 +628,7 @@ def OA_8_76():
PBD.remove([])

sets_of_size_seven = [R for R in PBD if len(R) == 7]
others = [R for R in PBD if len(R) != 7]
others = [R for R in PBD if len(R) != 7]

# critical_points are the 10 elements appearing twice in the rows of the 10
# sets_of_size_seven, and each row contains exactly two of them
Expand Down Expand Up @@ -1477,11 +1477,11 @@ def OA_17_560():
"""
from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF
alpha = 5
beta = 4
p = 2
k = 17
m = 16
n = p**alpha
beta = 4
p = 2
k = 17
m = 16
n = p**alpha

G = GF((p, alpha), prefix='x')
G_set = sorted(G) # sorted by lexicographic order, G[1] = 1
Expand Down Expand Up @@ -3694,7 +3694,7 @@ def DM_52_6_1():
sage: _ = designs.difference_matrix(52,6)
"""
from sage.rings.finite_rings.finite_field_constructor import FiniteField
F4 = FiniteField(4,'z')
F4 = FiniteField(4,'z')
G13 = FiniteField(13)
G = F4.cartesian_product(G13)
z = F4('z')
Expand Down Expand Up @@ -3805,9 +3805,9 @@ def DM_56_8_1():
sage: _ = designs.difference_matrix(56,8)
"""
from sage.rings.finite_rings.finite_field_constructor import FiniteField
F8 = FiniteField(8,'z')
F7 = FiniteField(7)
G = F8.cartesian_product(F7)
F8 = FiniteField(8,'z')
F7 = FiniteField(7)
G = F8.cartesian_product(F7)

w = F8.primitive_element()
assert w**3 == w+1
Expand Down Expand Up @@ -3936,7 +3936,7 @@ def DM_75_8_1():

F3 = FiniteField(3)
F5 = FiniteField(5)
G = cartesian_product((F3,F5,F5))
G = cartesian_product((F3,F5,F5))

M = [
[(2,0,0), (0,0,0), (0,0,0), (1,0,0), (0,0,0), (1,0,0), (1,0,0), (0,0,0)],
Expand Down Expand Up @@ -4121,7 +4121,7 @@ def RBIBD_120_8_1():
BIBD = new_BIBD

r = {v:i for i,v in enumerate(x for x in range(n) if x not in hyperoval)}
BIBD = [[r[x] for x in B] for B in BIBD ]
BIBD = [[r[x] for x in B] for B in BIBD ]
equiv = [[r[x] for x in B] for B in equiv]

BIBD = IncidenceStructure(range(255),BIBD)
Expand Down Expand Up @@ -5008,13 +5008,13 @@ def BIBD_56_11_2():
for k in sorted(EDS))

__doc__ = __doc__.format(
LIST_OF_OA_CONSTRUCTIONS = LIST_OF_OA_CONSTRUCTIONS,
LIST_OF_OA_CONSTRUCTIONS = LIST_OF_OA_CONSTRUCTIONS,
LIST_OF_MOLS_CONSTRUCTIONS = LIST_OF_MOLS_CONSTRUCTIONS,
LIST_OF_VMT_VECTORS = LIST_OF_VMT_VECTORS,
LIST_OF_BIBD = LIST_OF_BIBD,
LIST_OF_DF = LIST_OF_DF,
LIST_OF_DM = LIST_OF_DM,
LIST_OF_QDM = LIST_OF_QDM,
LIST_OF_EDS = LIST_OF_EDS)
LIST_OF_VMT_VECTORS = LIST_OF_VMT_VECTORS,
LIST_OF_BIBD = LIST_OF_BIBD,
LIST_OF_DF = LIST_OF_DF,
LIST_OF_DM = LIST_OF_DM,
LIST_OF_QDM = LIST_OF_QDM,
LIST_OF_EDS = LIST_OF_EDS)
del LIST_OF_OA_CONSTRUCTIONS, LIST_OF_MOLS_CONSTRUCTIONS, LIST_OF_VMT_VECTORS,LIST_OF_DF, LIST_OF_DM, LIST_OF_QDM, LIST_OF_EDS, LIST_OF_BIBD
del PolynomialRing, ZZ, a,
Loading

0 comments on commit a493495

Please sign in to comment.