Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #33486: fix indentation (E111) in some pyx files
Browse files Browse the repository at this point in the history
URL: https://trac.sagemath.org/33486
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Matthias Koeppe
  • Loading branch information
Release Manager committed Mar 10, 2022
2 parents 273836b + 801c068 commit 4eea459
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 129 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=f82b40417a8c050b2ea0b6e15ef7291801325432
md5=89cd19b31c6b6da6f6a0964de5fb960f
cksum=1750781409
sha1=acd2166b712d910e83d89f9cbc28d786632b6be8
md5=dd823be0c5983a7f9afeb371cf651547
cksum=1397772811
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6b5920b4aa88af53cb01b487bfe7eb0868a447fe
509be3f5aaf552403e34ed35d936c72a26e6c5ab
6 changes: 3 additions & 3 deletions src/sage/arith/multi_modular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ cdef class MultiModularBasis_base(object):
"""
sig_free(self.moduli)
for i in range(self.n):
mpz_clear(self.partial_products[i])
mpz_clear(self.partial_products[i])
sig_free(self.partial_products)
sig_free(self.C)
mpz_clear(self.product)
Expand Down Expand Up @@ -487,9 +487,9 @@ cdef class MultiModularBasis_base(object):
count = self.n * mpz_sizeinbase(height, 2) / mpz_sizeinbase(self.partial_products[self.n-1], 2) # an estimate
count = max(min(count, self.n), 1)
while count > 1 and mpz_cmp(height, self.partial_products[count-1]) < 0:
count -= 1
count -= 1
while mpz_cmp(height, self.partial_products[count-1]) > 0:
count += 1
count += 1

return count

Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ cdef class Action(Functor):
return S

def codomain(self):
return self.underlying_set()
return self.underlying_set()

def domain(self):
return self.underlying_set()
Expand Down Expand Up @@ -454,7 +454,7 @@ cdef class PrecomposedAction(Action):
if right_precomposition is not None:
rco = right_precomposition._codomain
if rco is not right:
right_precomposition = homset.Hom(rco, right).natural_map() * right_precomposition
right_precomposition = homset.Hom(rco, right).natural_map() * right_precomposition
right = right_precomposition.domain()
if action._is_left:
Action.__init__(self, left, US, 1)
Expand Down
29 changes: 15 additions & 14 deletions src/sage/combinat/degree_sequences.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -441,24 +441,25 @@ cdef init(int n):
return sequences

cdef inline add_seq():
"""
This function is called whenever a sequence is found.
"""
This function is called whenever a sequence is found.
Build the degree sequence corresponding to the current state of the
algorithm and adds it to the sequences list.
"""
global sequences
global N
global seq

Build the degree sequence corresponding to the current state of the
algorithm and adds it to the sequences list.
"""
global sequences
global N
global seq
cdef list s = []
cdef int i, j

cdef list s = []
cdef int i, j
for N > i >= 0:
for 0 <= j < seq[i]:
s.append(i)

for N > i >= 0:
for 0<= j < seq[i]:
s.append(i)
sequences.append(s)

sequences.append(s)

cdef void enum(int k, int M):
r"""
Expand Down
99 changes: 50 additions & 49 deletions src/sage/ext/fast_callable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1483,55 +1483,56 @@ cdef class ExpressionChoice(Expression):
repr(self._iffalse))

cpdef _expression_binop_helper(s, o, op):
r"""
Make an Expression for (s op o). Either s or o (or both) must already
be an expression.
EXAMPLES::
sage: from sage.ext.fast_callable import _expression_binop_helper, ExpressionTreeBuilder
sage: var('x,y')
(x, y)
sage: etb = ExpressionTreeBuilder(vars=(x,y))
sage: x = etb(x)
Now x is an Expression, but y is not. Still, all the following
cases work::
sage: _expression_binop_helper(x, x, operator.add)
add(v_0, v_0)
sage: _expression_binop_helper(x, y, operator.add)
add(v_0, v_1)
sage: _expression_binop_helper(y, x, operator.add)
add(v_1, v_0)
"""
# The Cython way of handling operator overloading on cdef classes
# (which is inherited from Python) is quite annoying. Inside the
# code for a binary operator, you know that either the first or
# second argument (or both) is a member of your class, but you
# don't know which.

# If there is an arithmetic operator between an Expression and
# a non-Expression, I want to convert the non-Expression into
# an Expression. But to do that, I need the ExpressionTreeBuilder
# from the Expression.

cdef Expression self
cdef Expression other

if not isinstance(o, Expression):
self = s
other = self._etb(o)
elif not isinstance(s, Expression):
other = o
self = other._etb(s)
else:
self = s
other = o
assert self._etb is other._etb

return ExpressionCall(self._etb, op, [self, other])
r"""
Make an Expression for (s op o). Either s or o (or both) must already
be an expression.
EXAMPLES::
sage: from sage.ext.fast_callable import _expression_binop_helper, ExpressionTreeBuilder
sage: var('x,y')
(x, y)
sage: etb = ExpressionTreeBuilder(vars=(x,y))
sage: x = etb(x)
Now x is an Expression, but y is not. Still, all the following
cases work::
sage: _expression_binop_helper(x, x, operator.add)
add(v_0, v_0)
sage: _expression_binop_helper(x, y, operator.add)
add(v_0, v_1)
sage: _expression_binop_helper(y, x, operator.add)
add(v_1, v_0)
"""
# The Cython way of handling operator overloading on cdef classes
# (which is inherited from Python) is quite annoying. Inside the
# code for a binary operator, you know that either the first or
# second argument (or both) is a member of your class, but you
# don't know which.

# If there is an arithmetic operator between an Expression and
# a non-Expression, I want to convert the non-Expression into
# an Expression. But to do that, I need the ExpressionTreeBuilder
# from the Expression.

cdef Expression self
cdef Expression other

if not isinstance(o, Expression):
self = s
other = self._etb(o)
elif not isinstance(s, Expression):
other = o
self = other._etb(s)
else:
self = s
other = o
assert self._etb is other._etb

return ExpressionCall(self._etb, op, [self, other])


class IntegerPowerFunction(object):
r"""
Expand Down
5 changes: 3 additions & 2 deletions src/sage/graphs/bliss.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -861,15 +861,16 @@ cdef Graph *bliss_graph(G, partition, vert2int, int2vert):
vert2int[v] = i
int2vert[i] = v

for x,y in G.edge_iterator(labels=False):
g.add_edge(vert2int[x], vert2int[y])
for x, y in G.edge_iterator(labels=False):
g.add_edge(vert2int[x], vert2int[y])

if partition:
for i in range(1, len(partition)):
for v in partition[i]:
g.change_color(vert2int[v], i)
return g


cdef Digraph *bliss_digraph(G, partition, vert2int, int2vert):
r"""
Return a bliss copy of a digraph G
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/distances_all_pairs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def is_distance_regular(G, parameters=False):
for u in range(n):
for v in range(n):
if u == v:
continue
continue

d = distance_matrix[u * n + v]
if d == infinity:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph_coloring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ def b_coloring(g, k, value_only=True, solver=None, verbose=0,

# a color class is used if and only if it has one b-vertex
for i in range(k):
p.add_constraint(p.sum(b[w,i] for w in g) - is_used[i], min=0, max=0)
p.add_constraint(p.sum(b[w,i] for w in g) - is_used[i], min=0, max=0)


# We want to maximize the number of used colors
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/strongly_regular_db.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ def is_unitary_dual_polar(int v,int k,int l,int mu):
if p**t != q or t % 2:
return
if (r < 0 and q != -r - 1) or (s < 0 and q != -s - 1):
return
return
t //= 2
# we have correct mu, negative eigenvalue, and q=p^(2t)
if (v == (q**2*p**t + 1)*(q*p**t + 1) and
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/trees.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ cdef class TreeIterator:
if p <= h1:
h1 = p - 1
if p <= r:
needr = 1
needr = 1
elif p <= h2:
needh2 = 1
needh2 = 1
elif l[h2 - 1] == l[h1 - 1] - 1 and n - h2 == r - h1:
if p <= c:
needc = 1
Expand Down
6 changes: 4 additions & 2 deletions src/sage/interacts/library_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ cpdef julia(ff_j, z, int iterations):
1.0 + 3.0*I
"""
for i in range(iterations):
z = ff_j(z)
if z.abs() > 2: break
z = ff_j(z)
if z.abs() > 2:
break
return z


cpdef mandel(ff_m, z, int iterations):
"""
Helper function for the Mandelbrot Fractal interact example.
Expand Down
14 changes: 7 additions & 7 deletions src/sage/matrix/matrix0.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ cdef class Matrix(sage.structure.element.Matrix):
row_list = normalize_index(row_index, nrows)
row_list_len = len(row_list)
if row_list_len==0:
return
return

if single_row and single_col and not no_col_index:
self.set_unsafe(row, col, self._coerce_element(value))
Expand Down Expand Up @@ -4720,16 +4720,16 @@ cdef class Matrix(sage.structure.element.Matrix):
[(0, 0), (1, 1)]
"""
x = self.fetch('nonzero_positions')
if not x is None:
if x is not None:
if copy:
return list(x)
return x
cdef Py_ssize_t i, j
nzp = []
for i from 0 <= i < self._nrows:
for j from 0 <= j < self._ncols:
if not self.get_is_zero_unsafe(i,j):
nzp.append((i,j))
for j from 0 <= j < self._ncols:
if not self.get_is_zero_unsafe(i, j):
nzp.append((i, j))
self.cache('nonzero_positions', nzp)
if copy:
return list(nzp)
Expand Down Expand Up @@ -4971,9 +4971,9 @@ cdef class Matrix(sage.structure.element.Matrix):
fac = o1.factor()
S = sum((pi - 1) * pi**(ei - 1) for pi, ei in fac)
if fac[0] == (2, 1):
impossible_order = not(S <= n + 1)
impossible_order = not(S <= n + 1)
else:
impossible_order = not(S <= n)
impossible_order = not(S <= n)
if impossible_order:
return Infinity

Expand Down
6 changes: 3 additions & 3 deletions src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ cdef class Matrix(Matrix1):
if (level - i) % 2:
d -= self.get_unsafe(level,level) * self._det_by_minors(level)
else:
d += self.get_unsafe(level,level) * self._det_by_minors(level)
d += self.get_unsafe(level,level) * self._det_by_minors(level)
# undo all our permutations to get us back to where we started
for i from 0 <= i < level:
self.swap_rows(level, i)
Expand Down Expand Up @@ -7426,7 +7426,7 @@ cdef class Matrix(Matrix1):
raise NotImplementedError("%s\nechelon form over %s not yet implemented"%(msg, self.base_ring()))

for c from 0 <= c < self.ncols():
for r from 0 <= r < self.nrows():
for r from 0 <= r < self.nrows():
self.set_unsafe(r, c, d.get_unsafe(r,c))
self.clear_cache()
self.cache('pivots', tuple(p))
Expand Down Expand Up @@ -8344,7 +8344,7 @@ cdef class Matrix(Matrix1):
# me + nc and me + 1 such that no entry is present already in the matrix.
S = [first_row[0] + ncols] + [None]*(ncols-1)
for j in range(1, ncols):
S[j] = S[j - 1] if first_row[j] == first_row[j - 1] else S[j - 1] - 1
S[j] = S[j - 1] if first_row[j] == first_row[j - 1] else S[j - 1] - 1
# If we want to sort the i-th row with respect to a symmetry determined
# by S, then we will just sort the augmented row [[S[j], PM[i, j]] :
# j in [1 .. nc]], S having lexicographic priority.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_rational_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ cdef class Matrix_rational_dense(Matrix_dense):
num, den = [str_to_bytes(n) for n in s.split('/')]
if fmpz_set_str(fmpq_mat_entry_num(self._matrix, i, j), num, 32) or \
fmpz_set_str(fmpq_mat_entry_den(self._matrix, i, j), den, 32):
raise RuntimeError("invalid pickle data")
raise RuntimeError("invalid pickle data")
else:
s = str_to_bytes(s)
if fmpz_set_str(fmpq_mat_entry_num(self._matrix, i, j), s, 32):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/misc/cachefunc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ cdef class CachedMethodCallerNoArgs(CachedFunction):
try:
F = getattr(inst.__class__,f)
except AttributeError:
F = getattr(inst,f)
F = getattr(inst,f)
if isinstance(F,CachedFunction):
f = F.f
else:
Expand Down Expand Up @@ -3634,8 +3634,8 @@ class FileCache(object):
del self._cache[key]
if os.path.exists(f + '.sobj'):
os.remove(f + '.sobj')
if os.path.exists(f + '.key.sobj'):
os.remove(f + '.key.sobj')
if os.path.exists(f + '.key.sobj'):
os.remove(f + '.key.sobj')


class DiskCachedFunction(CachedFunction):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/free_module_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
for i in range(self._degree):
ord = self[i].additive_order()
if isinstance(ord, AnInfinity):
return ord
return ord
v.append(ord)
from sage.arith.all import lcm
return lcm(v)
Expand Down
Loading

0 comments on commit 4eea459

Please sign in to comment.