Skip to content

Commit 78e06c7

Browse files
author
Release Manager
committed
gh-35687: some fixes for pycodestyle E275 <!-- 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 This fixes some E275 warnings (E275 missing whitespace after keyword) plus a few other things outside of `graphs`, `rings`, `misc`, `coding` and `combinat` for now <!-- 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 ]`. --> - [ ] The title is concise, informative, and self-explanatory. - [ ] 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: #35687 Reported by: Frédéric Chapoton Reviewer(s): Frédéric Chapoton, Matthias Köppe
2 parents 16a6651 + ded1602 commit 78e06c7

File tree

32 files changed

+122
-112
lines changed

32 files changed

+122
-112
lines changed

src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,22 @@
2323
- Reimundo Heluani (2019-08-09): Initial implementation.
2424
"""
2525

26-
#******************************************************************************
26+
# *****************************************************************************
2727
# Copyright (C) 2019 Reimundo Heluani <[email protected]>
2828
#
2929
# This program is free software: you can redistribute it and/or modify
3030
# it under the terms of the GNU General Public License as published by
3131
# the Free Software Foundation, either version 2 of the License, or
3232
# (at your option) any later version.
33-
# http://www.gnu.org/licenses/
34-
#*****************************************************************************
33+
# https://www.gnu.org/licenses/
34+
# ****************************************************************************
3535

3636
from .lie_conformal_algebra_with_structure_coefs import \
37-
LieConformalAlgebraWithStructureCoefficients
37+
LieConformalAlgebraWithStructureCoefficients
3838
from sage.matrix.special import identity_matrix
3939
from sage.structure.indexed_generators import standardize_names_index_set
4040

41+
4142
class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
4243
r"""
4344
The Weyl Lie conformal algebra.
@@ -132,7 +133,7 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None,
132133
from sage.matrix.matrix_space import MatrixSpace
133134
if ngens:
134135
from sage.rings.integer_ring import ZZ
135-
if not(ngens in ZZ and not ngens % 2):
136+
if not (ngens in ZZ and not ngens % 2):
136137
raise ValueError("ngens needs to be an even positive Integer, "
137138
f"got {ngens}")
138139
if gram_matrix is not None:
@@ -163,8 +164,9 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None,
163164
names, index_set = standardize_names_index_set(names=names,
164165
index_set=index_set,
165166
ngens=ngens)
166-
weyldict = { (i,j): {0: {('K',0): gram_matrix[index_set.rank(i),
167-
index_set.rank(j)]}} for i in index_set for j in index_set}
167+
weyldict = {(i, j): {0: {('K', 0): gram_matrix[index_set.rank(i),
168+
index_set.rank(j)]}}
169+
for i in index_set for j in index_set}
168170

169171
super().__init__(R, weyldict, names=names,
170172
latex_names=latex_names,
@@ -182,7 +184,7 @@ def _repr_(self):
182184
The Weyl Lie conformal algebra with generators (alpha0, alpha1, K) over Integer Ring
183185
"""
184186
return "The Weyl Lie conformal algebra with generators {} over {}"\
185-
.format(self.gens(),self.base_ring())
187+
.format(self.gens(), self.base_ring())
186188

187189
def gram_matrix(self):
188190
r"""

src/sage/crypto/block_cipher/des.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ def __repr__(self):
472472
DES block cipher with 16 rounds and the following key schedule:
473473
Original DES key schedule with 16 rounds
474474
"""
475-
return('DES block cipher with %s rounds and the following key '
476-
'schedule:\n%s' % (self._rounds, self.keySchedule.__repr__()))
475+
return ('DES block cipher with %s rounds and the following key '
476+
'schedule:\n%s' % (self._rounds, self.keySchedule.__repr__()))
477477

478478
def encrypt(self, plaintext, key):
479479
r"""

src/sage/crypto/mq/sr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def __ne__(self, other):
665665
sage: sr1 != sr2
666666
True
667667
"""
668-
return not(self == other)
668+
return not (self == other)
669669

670670
def sub_bytes(self, d):
671671
r"""

src/sage/games/quantumino.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ def __init__(self, aside, box=(5, 8, 2)):
424424
Quantumino solver for the box (5, 8, 2)
425425
Aside pentamino number: 9
426426
"""
427-
if not(0 <= aside < 17):
428-
raise ValueError("aside (=%s) must be between 0 and 16" % aside)
427+
if not (0 <= aside < 17):
428+
raise ValueError(f"aside (={aside}) must be between 0 and 16")
429429
self._aside = aside
430430
self._box = box
431431

src/sage/geometry/polyhedron/parent.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
Parents for Polyhedra
33
"""
44

5-
#*****************************************************************************
5+
# ****************************************************************************
66
# Copyright (C) 2014 Volker Braun <[email protected]>
77
#
88
# Distributed under the terms of the GNU General Public License (GPL)
9-
# http://www.gnu.org/licenses/
10-
#******************************************************************************
9+
# https://www.gnu.org/licenses/
10+
# *****************************************************************************
1111

1212
from sage.structure.parent import Parent
1313
from sage.structure.element import get_coercion_model
@@ -193,7 +193,7 @@ def Polyhedra(ambient_space_or_base_ring=None, ambient_dim=None, backend=None, *
193193
return Polyhedra_field(base_ring.fraction_field(), ambient_dim, backend)
194194
else:
195195
raise ValueError('No such backend (=' + str(backend) +
196-
') implemented for given basering (=' + str(base_ring)+').')
196+
') implemented for given basering (=' + str(base_ring) + ').')
197197

198198

199199
class Polyhedra_base(UniqueRepresentation, Parent):
@@ -400,10 +400,10 @@ def some_elements(self):
400400
points = []
401401
R = self.base_ring()
402402
for i in range(self.ambient_dim() + 5):
403-
points.append([R(i*j^2) for j in range(self.ambient_dim())])
403+
points.append([R(i*j ^ 2) for j in range(self.ambient_dim())])
404404
return [
405-
self.element_class(self, [points[0:self.ambient_dim()+1], [], []], None),
406-
self.element_class(self, [points[0:1], points[1:self.ambient_dim()+1], []], None),
405+
self.element_class(self, [points[0:self.ambient_dim() + 1], [], []], None),
406+
self.element_class(self, [points[0:1], points[1:self.ambient_dim() + 1], []], None),
407407
self.element_class(self, [points[0:3], points[4:5], []], None),
408408
self.element_class(self, None, None)]
409409

@@ -421,7 +421,7 @@ def zero(self):
421421
sage: p + p == p
422422
True
423423
"""
424-
Vrep = [[[self.base_ring().zero()]*self.ambient_dim()], [], []]
424+
Vrep = [[[self.base_ring().zero()] * self.ambient_dim()], [], []]
425425
return self.element_class(self, Vrep, None)
426426

427427
def empty(self):
@@ -454,7 +454,7 @@ def universe(self):
454454
True
455455
"""
456456
R = self.base_ring()
457-
return self(None, [[[R.one()]+[R.zero()]*self.ambient_dim()], []], convert=True)
457+
return self(None, [[[R.one()] + [R.zero()] * self.ambient_dim()], []], convert=True)
458458

459459
@cached_method
460460
def Vrepresentation_space(self):
@@ -502,10 +502,9 @@ def Hrepresentation_space(self):
502502
"""
503503
if self.base_ring() in Fields():
504504
from sage.modules.free_module import VectorSpace
505-
return VectorSpace(self.base_ring(), self.ambient_dim()+1)
506-
else:
507-
from sage.modules.free_module import FreeModule
508-
return FreeModule(self.base_ring(), self.ambient_dim()+1)
505+
return VectorSpace(self.base_ring(), self.ambient_dim() + 1)
506+
from sage.modules.free_module import FreeModule
507+
return FreeModule(self.base_ring(), self.ambient_dim() + 1)
509508

510509
def _repr_base_ring(self):
511510
"""
@@ -576,7 +575,7 @@ def _repr_(self):
576575
sage: Polyhedra(QQ, 3)._repr_()
577576
'Polyhedra in QQ^3'
578577
"""
579-
return 'Polyhedra in '+self._repr_ambient_module()
578+
return 'Polyhedra in ' + self._repr_ambient_module()
580579

581580
def _element_constructor_(self, *args, **kwds):
582581
"""
@@ -677,7 +676,7 @@ def convert_base_ring_Hrep(lstlst):
677676
if m == 0:
678677
newlstlst.append(lst)
679678
else:
680-
newlstlst.append([q/m for q in lst])
679+
newlstlst.append([q / m for q in lst])
681680
else:
682681
newlstlst.append(lst)
683682
return convert_base_ring(newlstlst)
@@ -902,14 +901,14 @@ def _coerce_base_ring(self, other):
902901
except TypeError:
903902
pass
904903
if other_ring is None:
905-
raise TypeError('Could not coerce '+str(other)+' into ZZ, QQ, or RDF.')
904+
raise TypeError(f'Could not coerce {other} into ZZ, QQ, or RDF.')
906905

907906
if not other_ring.is_exact():
908907
other_ring = RDF # the only supported floating-point numbers for now
909908

910909
cm_map, cm_ring = get_coercion_model().analyse(self.base_ring(), other_ring)
911910
if cm_ring is None:
912-
raise TypeError('Could not coerce type '+str(other)+' into ZZ, QQ, or RDF.')
911+
raise TypeError(f'Could not coerce type {other} into ZZ, QQ, or RDF.')
913912
return cm_ring
914913

915914
def _coerce_map_from_(self, X):
@@ -1214,9 +1213,11 @@ def _element_constructor_polyhedron(self, polyhedron, **kwds):
12141213
else:
12151214
return Polyhedra_base._element_constructor_polyhedron(self, polyhedron, **kwds)
12161215

1216+
12171217
class Polyhedra_ZZ_normaliz(Polyhedra_base):
12181218
Element = Polyhedron_ZZ_normaliz
12191219

1220+
12201221
class Polyhedra_QQ_ppl(Polyhedra_base):
12211222
Element = Polyhedron_QQ_ppl
12221223

@@ -1246,27 +1247,35 @@ def _element_constructor_polyhedron(self, polyhedron, **kwds):
12461247
else:
12471248
return Polyhedra_base._element_constructor_polyhedron(self, polyhedron, **kwds)
12481249

1250+
12491251
class Polyhedra_QQ_normaliz(Polyhedra_base):
12501252
Element = Polyhedron_QQ_normaliz
12511253

1254+
12521255
class Polyhedra_QQ_cdd(Polyhedra_base):
12531256
Element = Polyhedron_QQ_cdd
12541257

1258+
12551259
class Polyhedra_RDF_cdd(Polyhedra_base):
12561260
Element = Polyhedron_RDF_cdd
12571261

1262+
12581263
class Polyhedra_normaliz(Polyhedra_base):
12591264
Element = Polyhedron_normaliz
12601265

1266+
12611267
class Polyhedra_polymake(Polyhedra_base):
12621268
Element = Polyhedron_polymake
12631269

1270+
12641271
class Polyhedra_field(Polyhedra_base):
12651272
Element = Polyhedron_field
12661273

1274+
12671275
class Polyhedra_number_field(Polyhedra_base):
12681276
Element = Polyhedron_number_field
12691277

1278+
12701279
@cached_function
12711280
def does_backend_handle_base_ring(base_ring, backend):
12721281
r"""

src/sage/interfaces/qepcad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ def __init__(self, parent, lines):
24272427
index = (index,)
24282428
self._index = index
24292429

2430-
self._dimension = sum([r&1 for r in index])
2430+
self._dimension = sum([r & 1 for r in index])
24312431
if 'Level ' in line:
24322432
self._level = int(line.split(':')[1].strip())
24332433
if 'Number of children' in line:

src/sage/logic/boolformula.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ def convert_opt(self, tree):
11671167
lval = ('prop', tree[1])
11681168
else:
11691169
lval = tree[1]
1170-
if not isinstance(tree[2], tuple) and not(tree[2] is None):
1170+
if not isinstance(tree[2], tuple) and tree[2] is not None:
11711171
rval = ('prop', tree[2])
11721172
else:
11731173
rval = tree[2]
@@ -1557,5 +1557,6 @@ def length(self):
15571557
# `len(self)`, but this may be deprecated in the future (see :trac:`32148`):
15581558
__len__ = length
15591559

1560+
15601561
# allow is_consequence to be called as a function (not only as a method of BooleanFormula)
15611562
is_consequence = BooleanFormula.is_consequence

src/sage/modular/arithgroup/congroup_gamma0.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def dimension_new_cusp_forms(self, k=2, p=0):
596596
N = self.level()
597597
k = ZZ(k)
598598

599-
if not(p == 0 or N % p):
599+
if not (p == 0 or N % p):
600600
return (self.dimension_cusp_forms(k) -
601601
2 * self.restrict(N // p).dimension_new_cusp_forms(k))
602602

src/sage/modular/btquotients/btquotient.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class BruhatTitsTree(SageObject, UniqueRepresentation):
412412
sage: T = BruhatTitsTree(4)
413413
Traceback (most recent call last):
414414
...
415-
ValueError: Input (4) must be prime
415+
ValueError: input (4) must be prime
416416
417417
AUTHORS:
418418
@@ -428,8 +428,8 @@ def __init__(self, p):
428428
sage: T = BruhatTitsTree(17)
429429
sage: TestSuite(T).run()
430430
"""
431-
if not(ZZ(p).is_prime()):
432-
raise ValueError('Input (%s) must be prime' % p)
431+
if not ZZ(p).is_prime():
432+
raise ValueError(f'input ({p}) must be prime')
433433
self._p = ZZ(p)
434434
self._Mat_22 = MatrixSpace(ZZ, 2, 2)
435435
self._mat_p001 = self._Mat_22([self._p, 0, 0, 1])
@@ -2283,7 +2283,7 @@ def _local_splitting(self, prec):
22832283
self._II = M([0, a, 1, 0])
22842284
z = 0
22852285
self._JJ = 0
2286-
while(self._JJ == 0):
2286+
while self._JJ == 0:
22872287
c = a * z * z + b
22882288
if c.is_square():
22892289
x = c.sqrt()

src/sage/modular/hypergeometric_motive.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,10 @@ def zigzag(self, x, flip_beta=False):
688688
alpha = self._alpha
689689
beta = self._beta
690690
if flip_beta:
691-
return(sum(1 for a in alpha if a <= x) -
692-
sum(1 for b in beta if 1 - b <= x))
693-
else:
694-
return(sum(1 for a in alpha if a <= x) -
695-
sum(1 for b in beta if b <= x))
691+
return (sum(1 for a in alpha if a <= x) -
692+
sum(1 for b in beta if 1 - b <= x))
693+
return (sum(1 for a in alpha if a <= x) -
694+
sum(1 for b in beta if b <= x))
696695

697696
def weight(self):
698697
"""

0 commit comments

Comments
 (0)