Skip to content

Commit

Permalink
sagemathgh-38695: some care for pycodestyle E262 in pyx files
Browse files Browse the repository at this point in the history
    
just cleaning a little bit

E262 inline comment should start with '# '

### 📝 Checklist

- [x] The title is concise and informative.
- [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 and checked the documentation
preview.
    
URL: sagemath#38695
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Sep 26, 2024
2 parents fdbf334 + 3e580ff commit 6257216
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/sage/coding/codecan/codecan.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
self._init_partition_stack(P)
self._init_point_hyperplane_incidence()
self._start_Sn_backtrack() #start the main computation
self._start_Sn_backtrack() # start the main computation
# up to now, we just computed the permutational part of the group action
# compute the other components of the transporter
Expand Down
2 changes: 1 addition & 1 deletion src/sage/data_structures/bounded_integer_sequences.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ cdef class BoundedIntegerSequence:
if other is None or self is None:
raise TypeError('cannot concatenate bounded integer sequence and None')
myself = self # may result in a type error
right = other # --"--
right = other # --"--
if right.data.itembitsize != myself.data.itembitsize:
raise ValueError("can only concatenate bounded integer sequences of compatible bounds")
out = BoundedIntegerSequence.__new__(BoundedIntegerSequence, 0, None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ cpdef _fast_possible_periods(self, return_points=False):
for r in rvalues:
periods.add(period*r)
points_periods.append([P_proj, period*r])
if p == 2 or p == 3: #need e=1 for N=1, QQ
if p == 2 or p == 3: # need e=1 for N=1, QQ
periods.add(period*r*p)
points_periods.append([P_proj, period*r*p])
else:
Expand All @@ -141,7 +141,7 @@ cpdef _fast_possible_periods(self, return_points=False):
periods.add(period*r*p)
points_periods.append([P_proj, period*r])
points_periods.append([P_proj, period*r*p])
if p == 2: #need e=3 for N>1, QQ
if p == 2: # need e=3 for N>1, QQ
periods.add(period*r*4)
points_periods.append([P_proj, period*r*4])
periods.add(period*r*8)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/lcalc/lcalc_Lfunction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ cdef class Lfunction_I(Lfunction):
cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept:
cdef int N = len(dirichlet_coeff)
cdef Integer tmpi
cdef int * coeffs = new_ints(N+1) #lcalc ignores 0the coefficient
cdef int * coeffs = new_ints(N+1) # lcalc ignores 0th coefficient
for i from 0 <= i< N by 1:
tmpi=Integer(dirichlet_coeff[i])
coeffs[i+1] = mpz_get_si(tmpi.value)
Expand Down Expand Up @@ -628,9 +628,9 @@ cdef class Lfunction_D(Lfunction):
cdef int i
cdef RealNumber tmpr
cdef int N = len(dirichlet_coeff)
cdef double * coeffs = new_doubles(N+1)#lcalc ignores 0th position
for i from 0 <= i< N by 1:
tmpr=RRR(dirichlet_coeff[i])
cdef double * coeffs = new_doubles(N+1) # lcalc ignores 0th position
for i in range(N):
tmpr = RRR(dirichlet_coeff[i])
coeffs[i+1] = mpfr_get_d(tmpr.value, MPFR_RNDN)
self.thisptr=new_c_Lfunction_D(NAME, what_type, N, coeffs, Period, q, w, A, g, l, n_poles, p, r)
del_doubles(coeffs)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/libs/mpmath/ext_impl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts):
bneg = MPF_sgn(b) <= 0
if apos:
# real part
MPF_hypot(&t, a, b, wpopts) #t = abs(a+bi) + a
MPF_hypot(&t, a, b, wpopts) # t = abs(a+bi) + a
MPF_add(&t, &t, a, wpopts)
MPF_set(&u, &t)
mpz_sub_ui(u.exp, u.exp, 1) # u = t / 2
Expand All @@ -1276,10 +1276,10 @@ cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts):
MPF_sub(&t, &t, a, wpopts)
MPF_set(&u, &t)
mpz_sub_ui(u.exp, u.exp, 1) # u = t / 2
MPF_sqrt(d, &u, opts) # im = sqrt(u)
MPF_sqrt(d, &u, opts) # im = sqrt(u)
mpz_add_ui(t.exp, t.exp, 1) # t = 2*t
MPF_sqrt(&u, &t, wpopts) # u = sqrt(t)
MPF_div(c, &v, &u, opts) # re = b / u
MPF_div(c, &v, &u, opts) # re = b / u
if bneg:
MPF_neg(c, c)
MPF_neg(d, d)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/mpmath/ext_main.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ cdef MPopts global_opts
global_context = None

cdef class Context:
cdef public mpf, mpc, constant #, def_mp_function
cdef public mpf, mpc, constant # , def_mp_function
cdef public trap_complex
cdef public pretty

Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/ntl/ntl_ZZ_pX.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ cdef class ntl_ZZ_pX():
sage: f.derivative()
[7 0 19]
"""
cdef ntl_ZZ_pX r = self._new() #restores context
cdef ntl_ZZ_pX r = self._new() # restores context
sig_on()
ZZ_pX_diff(r.x, self.x)
sig_off()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix0.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3605,14 +3605,14 @@ cdef class Matrix(sage.structure.element.Matrix):
[-4 -5 2]
[ 3 4 5]
"""
self.check_row_bounds_and_mutability(i,i)
self.check_row_bounds_and_mutability(i, i)
if r < 0 or r >= A.nrows():
raise IndexError("invalid row")
# this function exists just because it is useful for modular symbols presentations.
cdef Py_ssize_t l
l = 0
for k in cols:
self.set_unsafe(i,l,-A.get_unsafe(r,k)) #self[i,l] = -A[r,k]
self.set_unsafe(i, l, -A.get_unsafe(r, k)) # self[i,l] = -A[r,k]
l += 1

def reverse_rows_and_columns(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_double_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense):
import scipy
import scipy.linalg
from numpy.linalg import LinAlgError
try: ## Standard error reporting for Sage.
try: # Standard error reporting for Sage.
M._matrix_numpy = scipy.linalg.inv(self._matrix_numpy)
except LinAlgError:
raise ZeroDivisionError("input matrix must be nonsingular")
Expand Down
16 changes: 8 additions & 8 deletions src/sage/misc/c3_controlled.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,11 @@ def C3_merge(list lists):
cdef bint next_item_found

while nbheads:
for i in range(nbheads): # from 0 <= i < nbheads:
for i in range(nbheads):
O = heads[i]
# Does O appear in none of the tails? ``all(O not in tail for tail in tailsets)``
next_item_found = True
for j in range(nbheads): #from 0 <= j < nbheads:
for j in range(nbheads):
if j == i:
continue
tailset = tailsets[j]
Expand All @@ -640,7 +640,7 @@ def C3_merge(list lists):
# Clear O from other heads, removing the line altogether
# if the tail is already empty.
# j goes down so that ``del heads[j]`` does not screw up the numbering
for j in range(nbheads-1, -1, -1): # from nbheads > j >= 0:
for j in range(nbheads-1, -1, -1):
if heads[j] == O: # is O
tail = tails[j]
if tail:
Expand Down Expand Up @@ -860,7 +860,7 @@ cpdef tuple C3_sorted_merge(list lists, key=identity):
# Find the position of the largest head which will become the next item
max_i = 0
max_key = key(heads[0])
for i in range(1, nbheads): #from 1 <= i < nbheads:
for i in range(1, nbheads):
O = heads[i]
O_key = key(O)
if O_key > max_key:
Expand All @@ -870,14 +870,14 @@ cpdef tuple C3_sorted_merge(list lists, key=identity):

# Find all the bad choices
max_bad = None
for i in range(max_i): #from 0 <= i < max_i:
for i in range(max_i):
O = heads[i]
# Does O appear in none of the tails?
O_key = key(O)
# replace the closure
# if any(O_key in tailsets[j] for j in range(nbheads) if j != i): continue
cont = False
for j from 0<=j<i:
for j in range(i):
if O_key in tailsets[j]:
cont = True
break
Expand Down Expand Up @@ -936,7 +936,7 @@ cpdef tuple C3_sorted_merge(list lists, key=identity):
# Clear O from other heads, removing the line altogether
# if the tail is already empty.
# j goes down so that ``del heads[j]`` does not screw up the numbering
for j in range(nbheads-1, -1, -1):#from nbheads > j >= 0:
for j in range(nbheads-1, -1, -1):
if heads[j] == max_value:
tail = tails[j]
if tail:
Expand Down Expand Up @@ -1053,7 +1053,7 @@ class HierarchyElement(object, metaclass=ClasscallMetaclass):
[<class '44.cls'>, <class '43.cls'>, <class '42.cls'>, <class '41.cls'>, <class '40.cls'>, <class '39.cls'>, <class '38.cls'>, <class '37.cls'>, <class '36.cls'>, <class '35.cls'>, <class '34.cls'>, <class '33.cls'>, <class '32.cls'>, <class '31.cls'>, <class '30.cls'>, <class '29.cls'>, <class '28.cls'>, <class '27.cls'>, <class '26.cls'>, <class '25.cls'>, <class '24.cls'>, <class '23.cls'>, <class '22.cls'>, <class '21.cls'>, <class '20.cls'>, <class '19.cls'>, <class '18.cls'>, <class '17.cls'>, <class '16.cls'>, <class '15.cls'>, <class '14.cls'>, <class '13.cls'>, <class '12.cls'>, <class '11.cls'>, <class '10.cls'>, <class '9.cls'>, <class '8.cls'>, <class '7.cls'>, <class '6.cls'>, <class '5.cls'>, <class '4.cls'>, <class '3.cls'>, <class '2.cls'>, <class '1.cls'>, <class '0.cls'>, <... 'object'>]
"""
@staticmethod
def __classcall__(cls, value, succ, key = None):
def __classcall__(cls, value, succ, key=None):
"""
EXAMPLES::
Expand Down
10 changes: 5 additions & 5 deletions src/sage/misc/function_mangling.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ cdef class ArgumentFixer:
else:
self._default_tuple = tuple(defaults)

#code = f.__code__
# code = f.__code__

self.f = f
self._ndefault = len(defaults)
if classmethod:
self._nargs = len(arg_names)-1 #code.co_argcount-1
self._arg_names = tuple(arg_names[1:]) #code.co_varnames[1:self._nargs+1]
self._nargs = len(arg_names)-1 # code.co_argcount-1
self._arg_names = tuple(arg_names[1:]) # code.co_varnames[1:self._nargs+1]
else:
self._nargs = len(arg_names) #code.co_argcount
self._arg_names = tuple(arg_names) #code.co_varnames[:self._nargs]
self._nargs = len(arg_names) # code.co_argcount
self._arg_names = tuple(arg_names) # code.co_varnames[:self._nargs]
self._classmethod = classmethod

cdef dict default_map
Expand Down
16 changes: 8 additions & 8 deletions src/sage/numerical/backends/cvxopt_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cdef class CVXOPTBackend(GenericBackend):
Mixed Integer Program (no objective, 0 variables, 0 constraints)
"""

cdef list objective_function #c_matrix
cdef list objective_function # c_matrix
cdef list G_matrix
cdef str prob_name
cdef bint is_maximize
Expand All @@ -65,7 +65,7 @@ cdef class CVXOPTBackend(GenericBackend):
sage: p = get_solver(solver='CVXOPT')
"""

self.objective_function = [] #c_matrix in the example for cvxopt
self.objective_function = [] # c_matrix in the example for cvxopt
self.G_matrix = []
self.prob_name = ''
self.obj_constant_term = 0
Expand All @@ -79,12 +79,12 @@ cdef class CVXOPTBackend(GenericBackend):
self.row_name_var = []
self.col_name_var = []

self.param = {"show_progress":False,
"maxiters":100,
"abstol":1e-7,
"reltol":1e-6,
"feastol":1e-7,
"refinement":0 }
self.param = {"show_progress": False,
"maxiters": 100,
"abstol": 1e-7,
"reltol": 1e-6,
"feastol": 1e-7,
"refinement": 0}
self.answer = {}
if maximization:
self.set_sense(+1)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/plot/plot3d/shapes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1162,14 +1162,14 @@ class Text(PrimitiveObject):
[[['select atomno = 1', 'color atom [102,102,255]', 'label "Hi"']],
[['select atomno = 2', 'color atom [102,102,255]', 'label "Bye"']]]
"""
cen = (0,0,0)
cen = (0, 0, 0)
if render_params.transform is not None:
cen = render_params.transform.transform_point(cen)
render_params.atom_list.append(cen)
atom_no = len(render_params.atom_list)
return ['select atomno = %s' % atom_no,
self.get_texture().jmol_str("atom"),
'label "%s"' % self.string] #.replace('\n', '|')]
'label "%s"' % self.string] # .replace('\n', '|')]

def threejs_repr(self, render_params):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1917,10 +1917,10 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
mpfr_mul(t1, self.__im, self.__im, rnd)

mpfr_add(t0, t0, t1, rnd) # now t0 is the norm
mpfr_div(x.__re, self.__re, t0, rnd) # x.__re = self.__re/norm
mpfr_div(x.__re, self.__re, t0, rnd) # x.__re = self.__re/norm

mpfr_neg(t1, self.__im, rnd)
mpfr_div(x.__im, t1, t0, rnd) # x.__im = -self.__im/norm
mpfr_div(x.__im, t1, t0, rnd) # x.__im = -self.__im/norm

mpfr_clear(t0)
mpfr_clear(t1)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/padics/padic_printing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ cdef class pAdicPrinter_class(SageObject):
return s
else:
count += 1
if count == max_unram_terms: #this will never trigger if max_unram_terms == -1
if count == max_unram_terms: # this will never trigger if max_unram_terms == -1
newj = len(L) - 1
while L[newj] == 0:
newj -= 1
Expand All @@ -1424,7 +1424,7 @@ cdef class pAdicPrinter_class(SageObject):
return s
else:
count += 1
if count == max_unram_terms: #this will never trigger if max_unram_terms == -1
if count == max_unram_terms: # this will never trigger if max_unram_terms == -1
newj = 0
while L[newj] == 0:
newj += 1
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10185,7 +10185,7 @@ cdef class Polynomial(CommutativePolynomial):
"""
# __getitem__ already returns a polynomial!!
# We must not have check=False, since 0 must not have _coeffs = [0].
return <Polynomial>self._parent(self[:n])#, check=False)
return <Polynomial>self._parent(self[:n]) # , check=False)

cdef _inplace_truncate(self, long prec):
return self.truncate(prec)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/polynomial/weil/weil_polynomials.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ class WeilPolynomials_iter():
coefflist.append(j)
modlist.append(k)
# Remove cofactor from initial coefficients
if num_cofactor == 1: #cofactor x + sqrt(q)
if num_cofactor == 1: # cofactor x + sqrt(q)
for i in range(1, len(coefflist)):
coefflist[i] -= coefflist[i-1]*q.sqrt()
elif num_cofactor == 2: #cofactor x + sqrt(q)
elif num_cofactor == 2: # cofactor x + sqrt(q)
for i in range(1, len(coefflist)):
coefflist[i] += coefflist[i-1]*q.sqrt()
elif num_cofactor == 3: #cofactor x^2 - q
elif num_cofactor == 3: # cofactor x^2 - q
for i in range(2, len(coefflist)):
coefflist[i] += coefflist[i-2]*q
# Asymmetrize initial coefficients
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/power_series_ring_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,7 @@ def _solve_linear_de(R, N, L, a, b, f0):
g = _solve_linear_de(R, N, L2, a, b, f0)

term1 = R(g) # we must not have check=False, since otherwise [..., 0, 0] is not stripped
term2 = R(a[:L]) #, check=False)
term2 = R(a[:L]) # , check=False)
product = (term1 * term2).list()

# todo: perhaps next loop could be made more efficient
Expand Down
2 changes: 1 addition & 1 deletion src/sage/stats/time_series.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ cdef class TimeSeries:
sage: v
[20.0000, -3.0000, 4.5000, -2.0000]
"""
cnumpy.import_array() #This must be called before using the numpy C/api or you will get segfault
cnumpy.import_array() # This must be called before using the numpy C/api or you will get segfault
cdef cnumpy.npy_intp dims[1]
dims[0] = self._length
cdef cnumpy.ndarray n = cnumpy.PyArray_SimpleNewFromData(1, dims, cnumpy.NPY_DOUBLE, self._values)
Expand Down
Loading

0 comments on commit 6257216

Please sign in to comment.