Skip to content

Commit f102dea

Browse files
committed
Various lint fixes
1 parent ba2cec2 commit f102dea

File tree

7 files changed

+52
-42
lines changed

7 files changed

+52
-42
lines changed

src/flint/types/fmpz_mod_mat.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ cdef class fmpz_mod_mat(flint_mat):
413413
raise ZeroDivisionError("fmpz_mod_mat div: division by zero")
414414
else:
415415
raise DomainError("fmpz_mod_mat div: division by non-invertible element")
416-
return self._scalarmul(other.inverse())
416+
return self._scalarmul(inv)
417417

418418
def __add__(self, other):
419419
"""``M + N``: Add two matrices."""

src/flint/types/nmod.pxd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ cdef class nmod_ctx:
1212

1313
@staticmethod
1414
cdef nmod_ctx any_as_nmod_ctx(obj)
15+
1516
@staticmethod
1617
cdef nmod_ctx _get_ctx(int mod)
18+
1719
@staticmethod
1820
cdef nmod_ctx _new_ctx(ulong mod)
1921

2022
@cython.final
2123
cdef int any_as_nmod(self, mp_limb_t * val, obj) except -1
24+
2225
@cython.final
2326
cdef nmod new_nmod(self)
2427

src/flint/types/nmod.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cdef dict _nmod_ctx_cache = {}
2525
@cython.no_gc
2626
cdef class nmod_ctx:
2727
"""
28-
Context object for creating :class:`~.nmod` initalised
28+
Context object for creating :class:`~.nmod` initalised
2929
with modulus :math:`N`.
3030
3131
>>> ctx = nmod_ctx.new(17)

src/flint/types/nmod_mat.pxd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,28 @@ cdef class nmod_mat_ctx:
1919

2020
@staticmethod
2121
cdef nmod_mat_ctx any_as_nmod_mat_ctx(obj)
22+
2223
@staticmethod
2324
cdef nmod_mat_ctx _get_ctx(int mod)
25+
2426
@staticmethod
2527
cdef nmod_mat_ctx _new_ctx(ulong mod)
2628

2729
@cython.final
2830
cdef int any_as_nmod(self, mp_limb_t * val, obj) except -1
31+
2932
@cython.final
3033
cdef any_as_nmod_mat(self, obj)
34+
3135
@cython.final
3236
cdef nmod new_nmod(self)
37+
3338
@cython.final
3439
cdef nmod_poly new_nmod_poly(self)
40+
3541
@cython.final
3642
cdef nmod_mat new_nmod_mat(self, ulong m, ulong n)
43+
3744
@cython.final
3845
cdef nmod_mat new_nmod_mat_copy(self, nmod_mat other)
3946

src/flint/types/nmod_mat.pyx

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cimport cython
22

33
from flint.flintlib.flint cimport ulong, mp_limb_t
4-
from flint.flintlib.nmod cimport nmod_t
54

65
from flint.flintlib.fmpz_mat cimport fmpz_mat_nrows, fmpz_mat_ncols
76
from flint.flintlib.fmpz_mat cimport fmpz_mat_get_nmod_mat
@@ -123,7 +122,6 @@ cdef class nmod_mat_ctx:
123122
cdef any_as_nmod_mat(self, obj):
124123
"""Convert obj to nmod_mat or return NotImplemented."""
125124
cdef nmod_mat r
126-
cdef mp_limb_t v
127125

128126
if typecheck(obj, nmod_mat):
129127
return obj
@@ -181,38 +179,38 @@ cdef class nmod_mat_ctx:
181179
"""
182180
return self._is_prime
183181

184-
#def zero(self, slong m, slong n):
185-
# """Return the zero ``nmod_mat``.
186-
#
187-
# >>> ctx = nmod_mat_ctx.new(17)
188-
# >>> ctx.zero(2, 3)
189-
# [0, 0, 0]
190-
# [0, 0, 0]
191-
192-
# """
193-
# cdef nmod_mat r = self.new_nmod_mat()
194-
# nmod_mat_zero(r.val)
195-
# return r
196-
197-
#def one(self, slong m, slong n=-1):
198-
# """Return the one ``nmod_mat``.
199-
200-
# >>> ctx = nmod_mat_ctx.new(17)
201-
# >>> ctx.one(2)
202-
# [1, 0]
203-
# [0, 1]
204-
# >>> ctx.one(2, 3)
205-
# [1, 0, 0]
206-
# [0, 1, 0]
207-
208-
# """
209-
# cdef nmod_mat r = self.new_nmod_mat()
210-
# if n == -1:
211-
# n = m
212-
# n = min(m, n)
213-
# for i from 0 <= i < n:
214-
# nmod_mat_set_entry(r.val, i, i, 1)
215-
# return r
182+
#def zero(self, slong m, slong n):
183+
# """Return the zero ``nmod_mat``.
184+
#
185+
# >>> ctx = nmod_mat_ctx.new(17)
186+
# >>> ctx.zero(2, 3)
187+
# [0, 0, 0]
188+
# [0, 0, 0]
189+
190+
# """
191+
# cdef nmod_mat r = self.new_nmod_mat()
192+
# nmod_mat_zero(r.val)
193+
# return r
194+
195+
#def one(self, slong m, slong n=-1):
196+
# """Return the one ``nmod_mat``.
197+
198+
# >>> ctx = nmod_mat_ctx.new(17)
199+
# >>> ctx.one(2)
200+
# [1, 0]
201+
# [0, 1]
202+
# >>> ctx.one(2, 3)
203+
# [1, 0, 0]
204+
# [0, 1, 0]
205+
206+
# """
207+
# cdef nmod_mat r = self.new_nmod_mat()
208+
# if n == -1:
209+
# n = m
210+
# n = min(m, n)
211+
# for i from 0 <= i < n:
212+
# nmod_mat_set_entry(r.val, i, i, 1)
213+
# return r
216214

217215
def __str__(self):
218216
return f"Context for nmod_mat with modulus: {self.mod.n}"
@@ -491,9 +489,7 @@ cdef class nmod_mat(flint_mat):
491489
return r
492490

493491
def __rmul__(s, t):
494-
cdef nmod_mat_struct *sv
495492
cdef mp_limb_t c
496-
sv = &(<nmod_mat>s).val[0]
497493
if s.ctx.any_as_nmod(&c, t):
498494
return (<nmod_mat>s).__mul_nmod(c)
499495
u = s.ctx.any_as_nmod_mat(t)

src/flint/types/nmod_poly.pxd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ cdef class nmod_poly_ctx:
1717

1818
@staticmethod
1919
cdef nmod_poly_ctx any_as_nmod_poly_ctx(obj)
20+
2021
@staticmethod
2122
cdef nmod_poly_ctx _get_ctx(int mod)
23+
2224
@staticmethod
2325
cdef nmod_poly_ctx _new_ctx(ulong mod)
2426

2527
@cython.final
2628
cdef nmod_poly_set_list(self, nmod_poly_t poly, list val)
29+
2730
@cython.final
2831
cdef int any_as_nmod(self, mp_limb_t * val, obj) except -1
32+
2933
@cython.final
3034
cdef any_as_nmod_poly(self, obj)
35+
3136
@cython.final
3237
cdef nmod new_nmod(self)
38+
3339
@cython.final
3440
cdef nmod_poly new_nmod_poly(self)
3541

src/flint/types/nmod_poly.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from flint.flintlib.nmod_vec cimport *
1212
from flint.flintlib.nmod_poly cimport *
1313
from flint.flintlib.nmod_poly_factor cimport *
1414
from flint.flintlib.fmpz_poly cimport fmpz_poly_get_nmod_poly
15-
from flint.flintlib.ulong_extras cimport n_gcdinv, n_is_prime
1615

1716
from flint.utils.flint_exceptions import DomainError
1817

@@ -104,7 +103,6 @@ cdef class nmod_poly_ctx:
104103
n = PyList_GET_SIZE(val)
105104
nmod_poly_fit_length(poly, n)
106105
for i from 0 <= i < n:
107-
c = val[i]
108106
if self.any_as_nmod(&v, val[i]):
109107
nmod_poly_set_coeff_ui(poly, i, v)
110108
else:
@@ -393,7 +391,7 @@ cdef class nmod_poly(flint_poly):
393391
raise ValueError(f"{n = } must be positive")
394392

395393
if nmod_poly_get_coeff_ui(self.val, 0) == 0:
396-
raise ZeroDivisionError(f"nmod_poly inverse_series_trunc: leading coefficient is zero")
394+
raise ZeroDivisionError("nmod_poly inverse_series_trunc: leading coefficient is zero")
397395

398396
if not self.ctx._is_prime:
399397
raise DomainError(f"nmod_poly inverse_series_trunc: modulus {self.ctx.mod.n} is not prime")
@@ -840,7 +838,7 @@ cdef class nmod_poly(flint_poly):
840838

841839
def sqrt(nmod_poly self):
842840
"""Return exact square root or ``None``. """
843-
cdef nmod_poly
841+
cdef nmod_poly res
844842

845843
if not self.ctx._is_prime:
846844
raise DomainError(f"nmod_poly sqrt: modulus {self.ctx.mod.n} is not prime")

0 commit comments

Comments
 (0)