Skip to content

Commit 361ba99

Browse files
author
Release Manager
committed
gh-35770: cylint: remove some unused variables in rings/ <!-- 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 remove some of the many unused variables in pyx files in the `rings` folder, found using `cython-lint` <!-- 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: #35770 Reported by: Frédéric Chapoton Reviewer(s): Frédéric Chapoton, Matthias Köppe
2 parents 02ab700 + 390cc58 commit 361ba99

27 files changed

+78
-119
lines changed

src/sage/rings/bernoulli_mod_p.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,6 @@ def bernoulli_mod_p_single(long p, long k):
311311
if not sage.arith.all.is_prime(p):
312312
raise ValueError("p (=%s) must be a prime" % p)
313313

314-
R = Integers(p)
315-
316314
cdef long x = bernmm_bern_modp(p, k)
317315
if x == -1:
318316
raise ArithmeticError("B_k is not integral at p")

src/sage/rings/complex_arb.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ cimport sage.rings.abc
154154
cimport sage.rings.rational
155155

156156
from cpython.int cimport PyInt_AS_LONG
157-
from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
157+
from cpython.object cimport Py_EQ, Py_NE
158158
from cpython.complex cimport PyComplex_FromDoubles
159159

160160
from sage.ext.stdsage cimport PY_NEW
@@ -1402,7 +1402,6 @@ cdef class ComplexBall(RingElement):
14021402
"""
14031403
cdef fmpz_t tmpz
14041404
cdef fmpq_t tmpq
1405-
cdef long myprec
14061405
cdef bint cplx = False
14071406

14081407
Element.__init__(self, parent)
@@ -2426,17 +2425,15 @@ cdef class ComplexBall(RingElement):
24262425
False
24272426
"""
24282427
cdef ComplexBall lt, rt
2429-
cdef acb_t difference
24302428

24312429
lt = left
24322430
rt = right
24332431

24342432
if op == Py_EQ:
24352433
return acb_eq(lt.value, rt.value)
2436-
elif op == Py_NE:
2434+
if op == Py_NE:
24372435
return acb_ne(lt.value, rt.value)
2438-
elif op == Py_GT or op == Py_GE or op == Py_LT or op == Py_LE:
2439-
raise TypeError("No order is defined for ComplexBalls.")
2436+
raise TypeError("No order is defined for ComplexBalls.")
24402437

24412438
def identical(self, ComplexBall other):
24422439
"""

src/sage/rings/complex_mpc.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,6 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
816816
"""
817817
# This should not be called except when the number is being created.
818818
# Complex Numbers are supposed to be immutable.
819-
cdef RealNumber x
820819
cdef mpc_rnd_t rnd
821820
rnd =(<MPComplexField_class>self._parent).__rnd
822821
if y is None:
@@ -2338,12 +2337,11 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
23382337
sage: u.agm(v, algorithm="optimal")
23392338
-0.410522769709397 + 4.60061063922097*I
23402339
"""
2341-
if algorithm=="pari":
2340+
if algorithm == "pari":
23422341
t = self._parent(right).__pari__()
23432342
return self._parent(self.__pari__().agm(t))
23442343

23452344
cdef MPComplexNumber a, b, d, s, res
2346-
cdef mpfr_t sn,dn
23472345
cdef mp_exp_t rel_prec
23482346
cdef bint optimal = algorithm == "optimal"
23492347

src/sage/rings/fast_arith.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False):
146146
- Kevin Stueve (added primes iterator option) 2010-10-16
147147
- Robert Bradshaw (speedup using Pari prime table, py_ints option)
148148
"""
149-
cdef Integer z
150149
# input to pari.init_primes cannot be greater than 436273290 (hardcoded bound)
151150
DEF init_primes_max = 436273290
152151
DEF small_prime_max = 436273009 # a prime < init_primes_max (preferably the largest)

src/sage/rings/finite_rings/element_base.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ cdef class FiniteRingElement(CommutativeRingElement):
8181
sage: r = a._nth_root_common(29*283*3539*12345, False, "Johnston", False)
8282
sage: r**(29*283*3539*12345) == a
8383
True
84-
8584
"""
8685
K = self.parent()
8786
q = K.order()
@@ -96,7 +95,7 @@ cdef class FiniteRingElement(CommutativeRingElement):
9695
if gcd == q-1:
9796
if all: return []
9897
else: raise ValueError("no nth root")
99-
gcd, alpha, beta = n.xgcd(q-1) # gcd = alpha*n + beta*(q-1), so 1/n = alpha/gcd (mod q-1)
98+
gcd, alpha, _ = n.xgcd(q-1) # gcd = alpha*n + beta*(q-1), so 1/n = alpha/gcd (mod q-1)
10099
if gcd == 1:
101100
return [self**alpha] if all else self**alpha
102101

@@ -406,12 +405,11 @@ cdef class FinitePolyExtElement(FiniteRingElement):
406405
sage: e._vector_(reverse=True)
407406
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1)
408407
"""
409-
#vector(foo) might pass in ZZ
408+
# vector(foo) might pass in ZZ
410409
if isinstance(reverse, Parent):
411410
raise TypeError("Base field is fixed to prime subfield.")
412411

413412
k = self.parent()
414-
p = self.polynomial()
415413
ret = self.polynomial().padded_list(k.degree())
416414

417415
if reverse:
@@ -422,7 +420,9 @@ cdef class FinitePolyExtElement(FiniteRingElement):
422420
r"""
423421
Return the matrix of left multiplication by the element on
424422
the power basis `1, x, x^2, \ldots, x^{d-1}` for the field
425-
extension. Thus the \emph{columns} of this matrix give the images
423+
extension.
424+
425+
Thus the \emph{columns} of this matrix give the images
426426
of each of the `x^i`.
427427
428428
INPUT:

src/sage/rings/finite_rings/integer_mod.pyx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def Mod(n, m, parent=None):
147147
return n
148148

149149
# m is non-zero, so return n mod m
150-
cdef IntegerMod_abstract x
151150
if parent is None:
152151
from .integer_mod_ring import IntegerModRing
153152
parent = IntegerModRing(m)
@@ -1524,7 +1523,6 @@ cdef class IntegerMod_abstract(FiniteRingElement):
15241523
return K(p**(pval // n) * mod(upart, p**(k-pval)).nth_root(n, algorithm=algorithm).lift())
15251524
from sage.rings.padics.factory import ZpFM
15261525
R = ZpFM(p,k)
1527-
self_orig = self
15281526
if p == 2:
15291527
sign = [1]
15301528
if self % 4 == 3:
@@ -4034,9 +4032,6 @@ cpdef square_root_mod_prime(IntegerMod_abstract a, p=None):
40344032
cdef double bits = log2(float(p))
40354033
cdef long r, m
40364034

4037-
cdef Integer resZ
4038-
4039-
40404035
if p_mod_16 % 2 == 0: # p == 2
40414036
return a
40424037

src/sage/rings/function_field/element.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,15 @@ cdef class FunctionFieldElement(FieldElement):
655655
sage: (y/x + 1).evaluate(p) # optional - sage.rings.finite_rings sage.rings.function_field
656656
1
657657
"""
658-
R, fr_R, to_R = place._residue_field()
658+
R, _, to_R = place._residue_field()
659659

660660
v = self.valuation(place)
661661
if v > 0:
662662
return R.zero()
663-
elif v == 0:
663+
if v == 0:
664664
return to_R(self)
665-
else: # v < 0
666-
raise ValueError('has a pole at the place')
665+
# v < 0
666+
raise ValueError('has a pole at the place')
667667

668668
cpdef bint is_nth_power(self, n):
669669
r"""

src/sage/rings/function_field/element_polymod.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement):
298298
# reduce to the separable case
299299
poly = self._parent._polynomial
300300
if not poly.gcd(poly.derivative()).is_one():
301-
L, from_L, to_L = self._parent.separable_model(('t', 'w'))
301+
_, from_L, to_L = self._parent.separable_model(('t', 'w'))
302302
return from_L(to_L(self).nth_root(n))
303303

304304
constant_base_field = self._parent.constant_base_field()
@@ -347,7 +347,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement):
347347
# reduce to the separable case
348348
poly = self._parent._polynomial
349349
if not poly.gcd(poly.derivative()).is_one():
350-
L, from_L, to_L = self._parent.separable_model(('t', 'w'))
350+
_, _, to_L = self._parent.separable_model(('t', 'w'))
351351
return to_L(self).is_nth_power(n)
352352

353353
constant_base_field = self._parent.constant_base_field()

src/sage/rings/integer_ring.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain):
413413
return self
414414

415415
if isinstance(x, NumberFieldElement_base):
416-
K, from_K = parent(x).subfield(x)
416+
K, _ = parent(x).subfield(x)
417417
return K.order(K.gen())
418418

419419
return PrincipalIdealDomain.__getitem__(self, x)
@@ -1651,7 +1651,7 @@ def crt_basis(X, xgcd=None):
16511651
for i in range(len(X)):
16521652
p = X[i]
16531653
others = P // p
1654-
g, s, t = p.xgcd(others)
1654+
g, _, t = p.xgcd(others)
16551655
if g != ONE:
16561656
raise ArithmeticError("the elements of the list X must be coprime in pairs")
16571657
Y.append(t * others)

src/sage/rings/laurent_series_ring_element.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,6 @@ cdef class LaurentSeries(AlgebraElement):
12551255
deg = prec - 1
12561256

12571257
cdef long i
1258-
cdef int c
12591258
for i in range(val, deg + 1):
12601259
li = self[i]
12611260
ri = right[i]

0 commit comments

Comments
 (0)