Skip to content

Commit 3c071b3

Browse files
author
Release Manager
committed
gh-40829: a few fixes for pycodestyle some in recently introduced code ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40829 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents 7bb0818 + fb1fd89 commit 3c071b3

File tree

11 files changed

+32
-40
lines changed

11 files changed

+32
-40
lines changed

src/sage/graphs/connectivity.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ def blocks_and_cuts_tree(G):
777777
g.add_edge(('B', bloc), ('C', c))
778778
return g
779779

780+
780781
def biconnected_components_subgraphs(G):
781782
r"""
782783
Return a list of biconnected components as graph objects.
@@ -816,6 +817,7 @@ def biconnected_components_subgraphs(G):
816817

817818
return [G.subgraph(c) for c in blocks_and_cut_vertices(G)[0]]
818819

820+
819821
def is_edge_cut(G, edges):
820822
"""
821823
Check whether ``edges`` form an edge cut.

src/sage/interfaces/khoca.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def prepare_data(data):
182182
for i in data:
183183
# i[0]: degree, i[1]: height, i[2]: torsion i[3]: rank
184184
d, h, t, r = i
185-
# make d compatibil with Sage
186-
d = int(t/2) - d
185+
# make d compatible with Sage
186+
d = int(t / 2) - d
187187
if (h, d, t) in data_as_dict:
188188
data_as_dict[(h, d, t)] += r
189189
else:
@@ -207,9 +207,9 @@ def prepare_data(data):
207207
raw_data = khoca_raw_data(link, ring, red_typ=False, **kwds)
208208
if 'reduced' in kwds:
209209
red = kwds['reduced']
210-
if type(red) == bool:
210+
if isinstance(red, bool):
211211
if red:
212212
return raw_data['red']
213-
else:
214-
raise TypeError('reduced must be a boolean')
213+
else:
214+
raise TypeError('reduced must be a boolean')
215215
return raw_data['unred']

src/sage/interfaces/regina.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def set(self, var, value):
338338
"""
339339
self._lazy_init()
340340
globs = self._regina_globals
341-
if type(value) != str:
341+
if not isinstance(value, str):
342342
globs[var] = value
343343
return
344344
try:
@@ -428,7 +428,7 @@ def _convert_args_kwds(self, *args, **kwds):
428428
def convert_arg(arg):
429429
if isinstance(arg, InterfaceElement) and arg.parent() is self:
430430
return arg._inst
431-
elif type(arg) in (list, tuple):
431+
elif isinstance(arg, (list, tuple)):
432432
return type(arg)([convert_arg(i) for i in arg])
433433
elif hasattr(arg, '_regina_'):
434434
reg = arg._regina_(self)
@@ -832,9 +832,9 @@ def is_native(inst):
832832
if operation in ('+', '*'):
833833
if is_native(sinst) and is_native(oinst):
834834
if operation == '*':
835-
return P(sinst*oinst)
835+
return P(sinst * oinst)
836836
else:
837-
return P(sinst+oinst)
837+
return P(sinst + oinst)
838838
if type(sinst) == type(oinst):
839839
if hasattr(self, 'addTermsLast'):
840840
new = self.__deepcopy__()
@@ -860,7 +860,7 @@ def is_native(inst):
860860
return (~self)**(-exp)
861861
if operation == '1/':
862862
if is_native(sinst):
863-
return P(1/sinst)
863+
return P(1 / sinst)
864864
if hasattr(self, 'inverse'):
865865
return self.inverse()
866866
return super()._operation(operation, other=other)
@@ -919,7 +919,6 @@ def from_detail_str(lc):
919919
"""
920920
if locals:
921921
lc.update(locals)
922-
from sage.repl.preparse import implicit_mul
923922
from sage.misc.sage_eval import sage_eval
924923
s = self.detail().split('\n')[0]
925924
s = s.replace(' ', '')

src/sage/libs/gap/element.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@ cdef class GapElement(RingElement):
10061006
GAP_Leave()
10071007
gap_sig_off()
10081008

1009-
10101009
cdef bint _compare_less(self, Element other) except -2:
10111010
"""
10121011
Compare ``self`` with ``other``.
@@ -1030,7 +1029,6 @@ cdef class GapElement(RingElement):
10301029
GAP_Leave()
10311030
gap_sig_off()
10321031

1033-
10341032
cpdef _add_(self, right):
10351033
r"""
10361034
Add two GapElement objects.

src/sage/matrix/matrix2.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19588,7 +19588,7 @@ cdef class Matrix(Matrix1):
1958819588
k = row_profile_exhausted + row_profile_self + row_extension
1958919589

1959019590
# calculate sorting permutation, sort k by (shifts[c]+d, c)
19591-
k_rows = [x[2] for x in self._krylov_row_coordinates(shifts, degrees, k)]
19591+
k_rows = [x[2] for x in self._krylov_row_coordinates(shifts, degrees, k)]
1959219592
k_perm = Permutation([x + 1 for x in k_rows])
1959319593

1959419594
# fast calculation of rows formed by indices in k
@@ -19633,7 +19633,7 @@ cdef class Matrix(Matrix1):
1963319633
k = row_profile_exhausted + row_profile_self
1963419634
R = exhausted.stack(R)
1963519635

19636-
k_rows = [x[2] for x in self._krylov_row_coordinates(shifts, degrees, k)]
19636+
k_rows = [x[2] for x in self._krylov_row_coordinates(shifts, degrees, k)]
1963719637
k_perm = Permutation([x + 1 for x in k_rows])
1963819638

1963919639
R.permute_rows(k_perm)

src/sage/rings/finite_rings/integer_mod_ring.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,33 +1972,32 @@ def _roots_univariate_polynomial(self, f, ring=None, multiplicities=True, algori
19721972
if deg < 0:
19731973
# All residue classes are roots of the zero polynomial
19741974
return [*map(self, range(self.cardinality()))]
1975-
elif deg == 0:
1975+
if deg == 0:
19761976
return []
1977-
elif deg == 1:
1977+
if deg == 1:
19781978
# assume form a*x + b
19791979
b, a = f.list()
19801980
if a.is_unit():
19811981
return [-b * (~a)]
1982-
else:
1983-
al, bl = a.lift(), b.lift()
19841982

1985-
N = self.order()
1986-
g = N.gcd(al)
1983+
al, bl = a.lift(), b.lift()
1984+
1985+
N = self.order()
1986+
g = N.gcd(al)
19871987

1988-
if bl % g != 0:
1989-
return [] # No solution
1990-
else:
1991-
# whole eqn divided by g
1992-
N_by_g = N.divide_knowing_divisible_by(g)
1993-
a_by_g = al.divide_knowing_divisible_by(g)
1994-
_R = Zmod(N_by_g)
1995-
assert _R(a_by_g).is_unit()
1988+
if bl % g != 0:
1989+
return [] # No solution
19961990

1997-
# single root
1998-
_root = self(f.roots(_R, multiplicities=False)[0])
1999-
inc = self(N_by_g)
2000-
return [_root + k*inc for k in range(g)]
1991+
# whole eqn divided by g
1992+
N_by_g = N.divide_knowing_divisible_by(g)
1993+
a_by_g = al.divide_knowing_divisible_by(g)
1994+
_R = Zmod(N_by_g)
1995+
assert _R(a_by_g).is_unit()
20011996

1997+
# single root
1998+
_root = self(f.roots(_R, multiplicities=False)[0])
1999+
inc = self(N_by_g)
2000+
return [_root + k * inc for k in range(g)]
20022001

20032002
# Finite fields are a base case
20042003
if self.is_field():

src/sage/rings/function_field/element.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Any, List
22
from sage.structure.element import FieldElement
33

4-
54
class FunctionFieldElement(FieldElement):
65
_x: Any
76
_matrix: Any

src/sage/rings/function_field/element_polymod.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from sage.structure.richcmp import richcmp
33
from sage.structure.element import FieldElement
44
from sage.rings.function_field.element import FunctionFieldElement
55

6-
76
class FunctionFieldElement_polymod(FunctionFieldElement):
87
def __init__(self, parent: Any, x: Any, reduce: bool = True) -> None:
98
...

src/sage/rings/function_field/element_rational.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from sage.structure.richcmp import richcmp, richcmp_not_equal
33
from sage.structure.element import FieldElement
44
from sage.rings.function_field.element import FunctionFieldElement
55

6-
76
class FunctionFieldElement_rational(FunctionFieldElement):
87
def __init__(self, parent: Any, x: Any, reduce: bool = True) -> None:
98
...

src/sage/structure/element.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3215,7 +3215,7 @@ cdef class CommutativeRingElement(RingElement):
32153215
return I.reduce(self)
32163216

32173217

3218-
##############################################
3218+
##############################################
32193219

32203220
cdef class Expression(CommutativeRingElement):
32213221

0 commit comments

Comments
 (0)