Skip to content

Commit 2a03811

Browse files
author
Release Manager
committed
gh-35879: various cython-lint fixes in algebras,arith,calculus,categories <!-- 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 fixes some cython-lint warnings in the modified files, in the folders `algebras, arith, calculus, categories` <!-- 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 ]`. --> - [x] The title is concise, informative, and self-explanatory. - [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 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: #35879 Reported by: Frédéric Chapoton Reviewer(s): Matthias Köppe
2 parents 7287b45 + bfa7615 commit 2a03811

15 files changed

+54
-61
lines changed

src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
164164
"""
165165
cdef list L = []
166166
cdef FreeAlgebra_letterplace P = self._parent
167-
cdef int ngens = P.__ngens
168167
if P._base._repr_option('element_is_atomic'):
169168
for E, c in zip(self._poly.exponents(), self._poly.coefficients()):
170169
monstr = P.exponents_to_string(E)
@@ -239,7 +238,6 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
239238
"""
240239
cdef list L = []
241240
cdef FreeAlgebra_letterplace P = self._parent
242-
cdef int ngens = P.__ngens
243241
from sage.misc.latex import latex
244242
if P._base._repr_option('element_is_atomic'):
245243
for E, c in zip(self._poly.exponents(), self._poly.coefficients()):

src/sage/algebras/letterplace/free_algebra_letterplace.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
594594
cdef list tmp
595595
for i from 0<=i<nblocks:
596596
base = i*ngens
597-
tmp = [(j,E[base+j]) for j in range(ngens) if E[base+j]]
597+
tmp = [(j, E[base+j]) for j in range(ngens) if E[base+j]]
598598
if not tmp:
599599
continue
600600
var_ind, exp = tmp[0]
@@ -627,7 +627,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
627627
cdef list names = self.latex_variable_names()
628628
for i from 0<=i<nblocks:
629629
base = i*ngens
630-
tmp = [(j,E[base+j]) for j in range(ngens) if E[base+j]]
630+
tmp = [(j, E[base+j]) for j in range(ngens) if E[base+j]]
631631
if not tmp:
632632
continue
633633
var_ind, exp = tmp[0]

src/sage/algebras/octonion_algebra.pyx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ cdef class Octonion_generic(AlgebraElement):
389389
0
390390
"""
391391
cdef int i
392-
a, b, c = self._parent._params
393392
cdef tuple table = self._parent._mult_table
394393
ret = self.vec.get_unsafe(0) ** 2
395394
for i in range(1, 8):
@@ -782,13 +781,13 @@ class OctonionAlgebra(UniqueRepresentation, Parent):
782781
g = a * b * c
783782
self._mult_table = (
784783
((0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1)),
785-
((1, 1), (0, a), (3,-1), (2,-a), (5,-1), (4,-a), (7, 1), (6, a)),
786-
((2, 1), (3, 1), (0, b), (1, b), (6,-1), (7,-1), (4,-b), (5,-b)),
787-
((3, 1), (2, a), (1,-b), (0,-d), (7,-1), (6,-a), (5, b), (4, d)),
784+
((1, 1), (0, a), (3, -1), (2, -a), (5, -1), (4, -a), (7, 1), (6, a)),
785+
((2, 1), (3, 1), (0, b), (1, b), (6, -1), (7, -1), (4, -b), (5, -b)),
786+
((3, 1), (2, a), (1, -b), (0, -d), (7, -1), (6, -a), (5, b), (4, d)),
788787
((4, 1), (5, 1), (6, 1), (7, 1), (0, c), (1, c), (2, c), (3, c)),
789-
((5, 1), (4, a), (7, 1), (6, a), (1,-c), (0,-e), (3,-c), (2,-e)),
790-
((6, 1), (7,-1), (4, b), (5,-b), (2,-c), (3, c), (0,-f), (1, f)),
791-
((7, 1), (6,-a), (5, b), (4,-d), (3,-c), (2, e), (1,-f), (0, g)),
788+
((5, 1), (4, a), (7, 1), (6, a), (1, -c), (0, -e), (3, -c), (2, -e)),
789+
((6, 1), (7, -1), (4, b), (5, -b), (2, -c), (3, c), (0, -f), (1, f)),
790+
((7, 1), (6, -a), (5, b), (4, -d), (3, -c), (2, e), (1, -f), (0, g)),
792791
)
793792

794793
def _test_alternative(self, **options):

src/sage/algebras/quatalg/quaternion_algebra_element.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ from sage.categories.morphism cimport Morphism
88

99
cdef class QuaternionAlgebraElement_abstract(AlgebraElement):
1010
cpdef bint is_constant(self)
11-
cdef _do_print(self, x,y,z,w)
11+
cdef _do_print(self, x, y, z, w)
1212
cpdef conjugate(self)
1313
cpdef reduced_norm(self)
1414
cpdef reduced_trace(self)
1515

1616
cdef class QuaternionAlgebraElement_generic(QuaternionAlgebraElement_abstract):
1717
cdef object x, y, z, w
18-
# we will assume that our element has the representation
19-
# x + yi + zj + wk, where i^2 = a, j^2 = b
18+
# we will assume that our element has the representation
19+
# x + yi + zj + wk, where i^2 = a, j^2 = b
2020

2121
cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstract):
2222
cdef fmpz_poly_t x, y, z, w, a, b, modulus

src/sage/arith/functions.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
cpdef LCM_list(v)
22

33
cdef LCM_generic(itr, ret)
4-

src/sage/arith/multi_modular.pxd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ from sage.ext.mod_int cimport *
22
from sage.libs.gmp.types cimport mpz_t
33

44
cdef class MultiModularBasis_base():
5-
cdef int n
5+
cdef int n
66
cdef mod_int* moduli
7-
cdef mpz_t* partial_products
8-
cdef mod_int* C # precomputed values for CRT
9-
cdef mpz_t product
10-
cdef mpz_t half_product
7+
cdef mpz_t* partial_products
8+
cdef mod_int* C # precomputed values for CRT
9+
cdef mpz_t product
10+
cdef mpz_t half_product
1111
cdef unsigned long _l_bound
1212
cdef unsigned long _u_bound
1313
cdef unsigned long _num_primes

src/sage/arith/multi_modular.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ cdef class MultiModularBasis_base():
194194
the allowed interval; we will not return a prime in
195195
known_primes.
196196
"""
197-
cdef Py_ssize_t i
198197
cdef mod_int p
199198
while True:
200199
if len(known_primes) >= self._num_primes:
@@ -372,11 +371,10 @@ cdef class MultiModularBasis_base():
372371
return self.n
373372

374373
# find new prime moduli
375-
cdef int i
376374
new_moduli = []
377375
new_partial_products = []
378-
cdef Integer M # keeps current height
379-
cdef mod_int p # keeps current prime moduli
376+
cdef Integer M # keeps current height
377+
cdef mod_int p # keeps current prime moduli
380378

381379
if self.n == 0:
382380
M = smallInteger(1)
@@ -633,7 +631,6 @@ cdef class MultiModularBasis_base():
633631
if mpz_cmp(z[j], self.half_product) > 0:
634632
mpz_sub(z[j], z[j], self.product)
635633

636-
637634
cdef Integer zz
638635
zz = PY_NEW(Integer)
639636
mpz_set(zz.value, self.half_product)

src/sage/calculus/interpolation.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ cdef class Spline:
9292
...
9393
ValueError: Order of derivative must be 1 or 2.
9494
"""
95-
def __init__(self, v=[]):
95+
def __init__(self, v=None):
9696
"""
9797
EXAMPLES::
9898
@@ -101,7 +101,7 @@ cdef class Spline:
101101
sage: type(S)
102102
<class 'sage.calculus.interpolation.Spline'>
103103
"""
104-
self.v = list(v)
104+
self.v = [] if v is None else list(v)
105105
self.started = 0
106106

107107
def __dealloc__(self):
@@ -136,7 +136,7 @@ cdef class Spline:
136136
self.v[i] = xy
137137
else:
138138
for j from len(self.v) <= j <= i:
139-
self.v.append((0,0))
139+
self.v.append((0, 0))
140140
self.v[i] = xy
141141
self.stop_interp()
142142

src/sage/calculus/interpolators.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cimport numpy as np
2929
from math import pi
3030
cdef double TWOPI = 2*pi
3131

32+
3233
def polygon_spline(pts):
3334
"""
3435
Creates a polygon from a set of complex or `(x,y)` points. The polygon
@@ -61,6 +62,7 @@ def polygon_spline(pts):
6162
"""
6263
return PSpline(pts)
6364

65+
6466
cdef class PSpline:
6567
"""
6668
A ``CCSpline`` object contains a polygon interpolation of a figure
@@ -160,6 +162,7 @@ cdef class PSpline:
160162
pt2 = self.pts[(int(t1) + 1) % self.N]
161163
return (pt2 - pt1) * self.N / TWOPI
162164

165+
163166
def complex_cubic_spline(pts):
164167
"""
165168
Creates a cubic spline interpolated figure from a set of complex or
@@ -192,6 +195,7 @@ def complex_cubic_spline(pts):
192195
"""
193196
return CCSpline(pts)
194197

198+
195199
cdef class CCSpline:
196200
"""
197201
A ``CCSpline`` object contains a cubic interpolation of a figure
@@ -209,7 +213,7 @@ cdef class CCSpline:
209213
(0.9549296...-0.9549296...j)
210214
"""
211215
cdef int N
212-
cdef np.ndarray avec,bvec,cvec,dvec
216+
cdef np.ndarray avec, bvec, cvec, dvec
213217

214218
#standard cubic interpolation method
215219
def __init__(self, pts):
@@ -222,7 +226,7 @@ cdef class CCSpline:
222226
if isinstance(pts[0], tuple):
223227
pts = np.array(
224228
[complex(pt[0], pt[1]) for pt in pts], dtype=np.complex128)
225-
cdef int N, i, k
229+
cdef int N, i
226230
N = len(pts)
227231
yvec = np.zeros(N, dtype=np.complex128)
228232
for i in range(N):

src/sage/calculus/ode.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
cdef class ode_system:
22
cdef int c_j(self,double , double *, double *,double *)
33

4-
54
cdef int c_f(self,double t, double* , double* )
6-

0 commit comments

Comments
 (0)