Skip to content

Commit

Permalink
gh-35123: fixing most of pycodestyle E271
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 there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
### 📚 Description

This fixes most of pycodestyle E271 warnings (E271 multiple spaces after
keyword).

There remains only a few inside modular/

<!-- 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: #35123
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Mar 24, 2023
2 parents b2e6ba7 + eccca8a commit 9955e92
Show file tree
Hide file tree
Showing 32 changed files with 108 additions and 124 deletions.
4 changes: 1 addition & 3 deletions src/sage/algebras/fusion_rings/f_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
# Distributed under the terms of the GNU General Public License (GPL)
# https://www.gnu.org/licenses/
# ****************************************************************************


from copy import deepcopy
from ctypes import cast, py_object
from itertools import product, zip_longest
from multiprocessing import Pool, cpu_count, set_start_method, shared_memory
from multiprocessing import Pool, cpu_count, set_start_method, shared_memory
import numpy as np
from os import getpid, remove
import pickle
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/function_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _call_(self, x):
try:
return x.function_field()
except AttributeError:
raise TypeError("unable to canonically associate a function field to %s"%x)
raise TypeError("unable to canonically associate a function field to %s" % x)

class ParentMethods:
pass
Expand Down
10 changes: 5 additions & 5 deletions src/sage/coding/information_set_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,16 +479,16 @@ def decode(self, r):
# I was not an information set
continue
Gt = Gi_inv * G
#step 2.
# step 2.
y = r - vector([r[i] for i in I]) * Gt
g = Gt.rows()
#step 3.
for pi in range(p+1):
# step 3.
for pi in range(p + 1):
for A in itertools.combinations(range(k), pi):
for m in itertools.product(Fstar, repeat=pi):
e = y - sum(m[i]*g[A[i]] for i in range(pi))
e = y - sum(m[i] * g[A[i]] for i in range(pi))
errs = e.hamming_weight()
if errs >= tau[0] and errs <= tau[1]:
if tau[0] <= errs <= tau[1]:
return r - e

def calibrate(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/matrices/hadamard_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def williamson_hadamard_matrix_smallcases(n, existence=False, check=True):
"""
assert n % 4 == 0

if not williamson_type_quadruples_smallcases(n//4, existence=True):
if not williamson_type_quadruples_smallcases(n // 4, existence=True):
if existence:
return False
raise ValueError("The Williamson type Hadamard matrix of order %s is not yet implemented." % n)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/t_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from sage.structure.sequence import Sequence


def _nonperiodic_autocorrelation(sequences, j):
def _nonperiodic_autocorrelation(sequences, j):
r"""
Compute the nonperiodic autocorrelation of a familiy of sequences.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/crypto/mq/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,11 @@ def sbox(self, inversion_only=False):
if not inversion_only:
with AllowZeroInversionsContext(self):
S = [self.sub_byte(elem) for elem in sorted(k)]
return SBox(S)
return SBox(S)
else:
e = self.e
S = [elem ** (2**e - 2) for elem in sorted(k)]
return SBox(S)
return SBox(S)

def shift_rows(self, d):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/databases/knotinfo_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,10 @@ def _create_data_sobj(self, sobj_path=None):
for col in cols:
val_list = []

if col.column_type() != col.types.OnlyLinks:
for i in range(1 , len_knots):
if col.column_type() != col.types.OnlyLinks:
for i in range(1, len_knots):
if col.name == self._names_column:
row_dict[self._knot_prefix + knot_list[i][col.name]] = [i - 1 , 1]
row_dict[self._knot_prefix + knot_list[i][col.name]] = [i - 1, 1]

val_list.append(knot_list[i][col.name])

Expand Down
4 changes: 2 additions & 2 deletions src/sage/games/quantumino.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class QuantuminoSolver(SageObject):
Quantumino solver for the box (5, 4, 4)
Aside pentamino number: 12
"""
def __init__(self, aside, box=(5,8,2)):
def __init__(self, aside, box=(5, 8, 2)):
r"""
Constructor.
Expand All @@ -424,7 +424,7 @@ def __init__(self, aside, box=(5,8,2)):
Quantumino solver for the box (5, 8, 2)
Aside pentamino number: 9
"""
if not 0 <= aside < 17:
if not(0 <= aside < 17):
raise ValueError("aside (=%s) must be between 0 and 16" % aside)
self._aside = aside
self._box = box
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -6640,20 +6640,19 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
msg = 'all cones are solid when max_ambient_dim is zero.'
raise ValueError(msg)
if (max_ambient_dim is not None and
min_rays > 2*(max_ambient_dim - 1)):
min_rays > 2 * (max_ambient_dim - 1)):
msg = 'every cone is solid when '
msg += 'min_rays > 2*(max_ambient_dim - 1).'
raise ValueError(msg)
else:
if lattice.dimension() == 0:
msg = 'all cones in the given lattice are solid.'
raise ValueError(msg)
if min_rays > 2*(lattice.dimension() - 1):
if min_rays > 2 * (lattice.dimension() - 1):
msg = 'every cone is solid when min_rays > 2*(d - 1) '
msg += 'where d is the dimension of the given lattice.'
raise ValueError(msg)


# Now that we've sanity-checked our parameters, we can massage the
# min/maxes for (non-)solid cones. It doesn't violate the user's
# expectation to increase a minimum, decrease a maximum, or fix an
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def __hash__(self):
if self.domain().is_isometry_group_projective():
# Special care must be taken for projective groups
m = matrix(self._matrix.nrows(),
[abs(x) for x in self._matrix.list()])
[abs(x) for x in self._matrix.list()])
m.set_immutable()
else:
m = self._matrix
Expand Down
4 changes: 2 additions & 2 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -3335,8 +3335,8 @@ def index_of_max(iterable):
ccf = cf
# Now let us find out where the end of the
# next symmetry block is:
if h < c+1:
h = S[h-1]
if h < c + 1:
h = S[h - 1]
s = n_p
# Check through this block for each possible permutation
while s > 0:
Expand Down
22 changes: 13 additions & 9 deletions src/sage/geometry/polyhedron/base5.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,14 +934,14 @@ def product(self, other):
new_vertices = (tuple(x) + tuple(y)
for x in self.vertex_generator() for y in other.vertex_generator())

self_zero = tuple(0 for _ in range( self.ambient_dim()))
self_zero = tuple(0 for _ in range( self.ambient_dim()))
other_zero = tuple(0 for _ in range(other.ambient_dim()))

rays = chain((tuple(r) + other_zero for r in self.ray_generator()),
(self_zero + tuple(r) for r in other.ray_generator()))
rays = chain((tuple(r) + other_zero for r in self.ray_generator()),
(self_zero + tuple(r) for r in other.ray_generator()))

lines = chain((tuple(l) + other_zero for l in self.line_generator()),
(self_zero + tuple(l) for l in other.line_generator()))
lines = chain((tuple(l) + other_zero for l in self.line_generator()),
(self_zero + tuple(l) for l in other.line_generator()))

if self.n_vertices() == 0 or other.n_vertices() == 0:
# In this case we obtain the empty polyhedron.
Expand All @@ -950,11 +950,15 @@ def product(self, other):
rays = ()
lines = ()

ieqs = chain((tuple(i) + other_zero for i in self.inequality_generator()),
((i.b(),) + self_zero + tuple(i.A()) for i in other.inequality_generator()))
ieqs = chain((tuple(i) + other_zero
for i in self.inequality_generator()),
((i.b(),) + self_zero + tuple(i.A())
for i in other.inequality_generator()))

eqns = chain((tuple(e) + other_zero for e in self.equation_generator()),
((e.b(),) + self_zero + tuple(e.A()) for e in other.equation_generator()))
eqns = chain((tuple(e) + other_zero
for e in self.equation_generator()),
((e.b(),) + self_zero + tuple(e.A())
for e in other.equation_generator()))

pref_rep = 'Vrep' if self.n_vertices() + self.n_rays() + other.n_vertices() + other.n_rays() \
<= self.n_inequalities() + other.n_inequalities() else 'Hrep'
Expand Down
12 changes: 6 additions & 6 deletions src/sage/geometry/ribbon_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,19 +956,19 @@ def homology_basis(self):
[[25, 26]],
[[27, 28]]]
"""
aux_sigma = [list(x) for x in self._sigma.cycle_tuples(singletons=True)]
aux_sigma = [list(x) for x in self._sigma.cycle_tuples(singletons=True)]

basis = [[list(x)] for x in self.reduced()._rho.cycle_tuples()]

#Now we define center as the set of edges that were contracted
#in reduced() this set is contractible and can be define as the
#complement of reduced_rho in rho
# Now we define center as the set of edges that were contracted
# in reduced() this set is contractible and can be define as the
# complement of reduced_rho in rho

center = [list(x) for x in self._rho.cycle_tuples()
if (x not in self.reduced()._rho.cycle_tuples())]

#We define an auxiliary list 'vertices' that will contain the
#vertices (cycles of sigma) corresponding to each half edge.
# We define an auxiliary list 'vertices' that will contain the
# vertices (cycles of sigma) corresponding to each half edge.

vertices = []

Expand Down
14 changes: 5 additions & 9 deletions src/sage/geometry/riemannian_manifolds/parametrized_surface3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,28 +905,24 @@ def orthonormal_frame(self, coordinates='ext'):
0
sage: sphere.first_fundamental_form(frame_int[2], frame_int[2])
1
"""


from sage.symbolic.constants import pi

if coordinates not in ['ext', 'int']:
raise ValueError("Coordinate system must be exterior ('ext') "
"or interior ('int').")

c = self.first_fundamental_form_coefficient([1,1])
c = self.first_fundamental_form_coefficient([1, 1])
if coordinates == 'ext':
f1 = self.natural_frame()[1]

E1 = _simplify_full_rad(f1/sqrt(c))
E1 = _simplify_full_rad(f1 / sqrt(c))
E2 = _simplify_full_rad(
self.normal_vector(normalized=True).cross_product(E1))
else:
E1 = vector([_simplify_full_rad(1/sqrt(c)), 0])
E2 = (self.rotation(pi/2)*E1).simplify_full()
return {1:E1, 2:E2}

E1 = vector([_simplify_full_rad(1 / sqrt(c)), 0])
E2 = (self.rotation(pi / 2) * E1).simplify_full()
return {1: E1, 2: E2}

def orthonormal_frame_vector(self, index, coordinates='ext'):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -20933,7 +20933,7 @@ def plot3d(self, bgcolor=(1, 1, 1),
vertex_colors = {(1, 0, 0) : list(self)}

if color_by_label:
if edge_colors is None:
if edge_colors is None:
# do the coloring
edge_colors = self._color_by_label(format=color_by_label)
elif edge_colors is None:
Expand Down Expand Up @@ -20975,7 +20975,7 @@ def plot3d(self, bgcolor=(1, 1, 1),
vertex_size=vertex_size, pos3d=pos3d, **kwds)

if color_by_label:
if edge_colors is None:
if edge_colors is None:
# do the coloring
edge_colors = self._color_by_label(format=color_by_label)

Expand Down
17 changes: 7 additions & 10 deletions src/sage/groups/cubic_braid.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None,

if domain is not None:
if isinstance(domain, UniversalCyclotomicField):
if root_bur is None:
if root_bur is None:
if unitary:
root_bur = domain.gen(12)
else:
Expand Down Expand Up @@ -503,7 +503,7 @@ def find_root(domain):
except ValueError:
raise ValueError('characteristic must be in integer')

if not characteristic.is_zero() and not characteristic.is_prime():
if not characteristic.is_zero() and not characteristic.is_prime():
raise ValueError('characteristic must be a prime')
if characteristic.is_zero():
if unitary:
Expand Down Expand Up @@ -991,7 +991,6 @@ def _test_matrix_group(self, **options):
self._internal_test_attached_group(matrix_grpF7, tester)
return


def _test_reflection_group(self, **options):
r"""
Check the reflection group properties.
Expand All @@ -1007,15 +1006,14 @@ def _test_reflection_group(self, **options):
sage: CBG2 = CubicBraidGroup(2)
sage: CBG2._test_reflection_group()
"""
if self._cbg_type == CubicBraidGroup.type.Coxeter and self.is_finite() and self.strands() > 2:
if self._cbg_type == CubicBraidGroup.type.Coxeter and self.is_finite() and self.strands() > 2:
from sage.combinat.root_system.reflection_group_real import is_chevie_available
if is_chevie_available():
tester = self._tester(**options)
reflgrp = self.as_reflection_group()
self._internal_test_attached_group(reflgrp, tester)
return


# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# local utility-methods
Expand Down Expand Up @@ -1258,9 +1256,9 @@ def create_unitary_realization(self, m):
for j in range(mthird):
pos = 3*(j+1)-1
transvections.append(xbas[pos-1]) # t_{3i} = x_{3i-1}
if pos +1 < m:
if pos +1 < m:
transvections.append(xbas[pos-1]+xbas[pos]+xbas[pos+1]) # t_{3i+1} = x_{3i-1} + x_{3i} + x_{3i+1}
if pos +3 < m:
if pos +3 < m:
transvections.append(xbas[pos+1]+xbas[pos+2]+xbas[pos+3]) # t_{3i+2} = x_{3i+1} + x_{3i+2} + x_{3i+3}

# -----------------------------------------------------------
Expand Down Expand Up @@ -1797,8 +1795,8 @@ def as_reflection_group(self):

from sage.combinat.root_system.reflection_group_real import ReflectionGroup

if self.strands() == 2:
reflection_group = ReflectionGroup([2 ,1 ,1])
if self.strands() == 2:
reflection_group = ReflectionGroup([2, 1, 1])
elif self.strands() == 3:
reflection_group = ReflectionGroup(4)
elif self.strands() == 4:
Expand All @@ -1810,7 +1808,6 @@ def as_reflection_group(self):
reflection_group.register_conversion(hom_to_refl)
return reflection_group


# ----------------------------------------------------------------------------------
# classical invariant form returns the invariant form of the classical realization
# ----------------------------------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions src/sage/groups/perm_gps/cubegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,21 +431,21 @@ def cubie_colors(label, state0):
clr_any = named_colors['white']
state = inv_list(state0)
if label == 1:
return [clr_any, named_colors[color_of_square(state[1-1])], clr_any] #ulb,
return [clr_any, named_colors[color_of_square(state[1-1])], clr_any] #ulb,
if label == 2:
return [clr_any,named_colors[color_of_square(state[2-1])],clr_any] # ub,
return [clr_any,named_colors[color_of_square(state[2-1])],clr_any] # ub,
if label == 3:
return [clr_any, named_colors[color_of_square(state[3-1])], named_colors[color_of_square(state[27-1])]] # ubr,
return [clr_any, named_colors[color_of_square(state[3-1])], named_colors[color_of_square(state[27-1])]] # ubr,
if label == 4:
return [clr_any, named_colors[color_of_square(state[4-1])], clr_any] # ul,
return [clr_any, named_colors[color_of_square(state[4-1])], clr_any] # ul,
if label == 5:
return [clr_any, named_colors[color_of_square(state[5-1])], named_colors[color_of_square(state[26-1])]] # ur,
return [clr_any, named_colors[color_of_square(state[5-1])], named_colors[color_of_square(state[26-1])]] # ur,
if label == 6:
return [named_colors[color_of_square(state[17-1])], named_colors[color_of_square(state[6-1])], clr_any] # ufl,
return [named_colors[color_of_square(state[17-1])], named_colors[color_of_square(state[6-1])], clr_any] # ufl,
if label == 7:
return [named_colors[color_of_square(state[18-1])], named_colors[color_of_square(state[7-1])], clr_any] # uf,
return [named_colors[color_of_square(state[18-1])], named_colors[color_of_square(state[7-1])], clr_any] # uf,
if label == 8:
return [named_colors[color_of_square(state[19-1])], named_colors[color_of_square(state[8-1])], named_colors[color_of_square(state[25-1])]] # urf,
return [named_colors[color_of_square(state[19-1])], named_colors[color_of_square(state[8-1])], named_colors[color_of_square(state[25-1])]] # urf,
if label == 17:
return [named_colors[color_of_square(state[17-1])], named_colors[color_of_square(state[6-1])], clr_any] # flu
if label == 18:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interacts/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def _secant_method(f, a, b, maxn, h):
L = sum(line([(c,k*i), (d,k*i)]) for i, (c,d) in enumerate(intervals) )
L += sum(line([(c,k*i-k/4), (c,k*i+k/4)]) for i, (c,d) in enumerate(intervals) )
L += sum(line([(d,k*i-k/4), (d,k*i+k/4)]) for i, (c,d) in enumerate(intervals) )
S = sum(line([(c,f(c)), (d,f(d)), (d-(d-c)*f(d)/(f(d)-f(c)), 0)], color="green") for (c,d) in intervals)
S = sum(line([(c,f(c)), (d,f(d)), (d-(d-c)*f(d)/(f(d)-f(c)), 0)], color="green") for (c, d) in intervals)
show(P + L + S, xmin=a, xmax=b)


Expand Down
Loading

0 comments on commit 9955e92

Please sign in to comment.