Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixng some cython-lint suggestions #151

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cypari2/handle_error.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ AUTHORS:
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import absolute_import, division, print_function

from cpython cimport PyErr_Occurred

from cysignals.signals cimport sig_block, sig_unblock, sig_error

from .paridecl cimport *
Expand Down Expand Up @@ -99,7 +97,7 @@ class PariError(RuntimeError):
>>> PariError(11)
PariError(11)
"""
return "PariError(%d)"%self.errnum()
return "PariError(%d)" % self.errnum()

def __str__(self):
r"""
Expand Down
24 changes: 12 additions & 12 deletions cypari2/pari_instance.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ from .closure cimport _pari_init_closure
# when no explicit precision is given and the inputs are exact.
cdef long prec = prec_bits_to_words(53)


#################################################################
# conversions between various real precision models
#################################################################
Expand Down Expand Up @@ -632,10 +633,10 @@ cdef class Pari(Pari_auto):
# chances that something goes wrong here (for example, if we
# are out of memory).
printf("top = %p\navma = %p\nbot = %p\nsize = %lu\n",
<void*>pari_mainstack.top,
<void*>avma,
<void*>pari_mainstack.bot,
<unsigned long>pari_mainstack.rsize)
<void*>pari_mainstack.top,
<void*>avma,
<void*>pari_mainstack.bot,
<unsigned long>pari_mainstack.rsize)
fflush(stdout)

def __repr__(self):
Expand Down Expand Up @@ -1025,7 +1026,7 @@ cdef class Pari(Pari_auto):
set_pari_stack_size(s, sizemax)
if not silent:
print("PARI stack size set to {} bytes, maximum size set to {}".
format(self.stacksize(), self.stacksizemax()))
format(self.stacksize(), self.stacksizemax()))

@staticmethod
def pari_version():
Expand Down Expand Up @@ -1182,7 +1183,7 @@ cdef class Pari(Pari_auto):
return new_gen(mpfact(n))

def polsubcyclo(self, long n, long d, v=None):
"""
r"""
polsubcyclo(n, d, v=x): return the pari list of polynomial(s)
defining the sub-abelian extensions of degree `d` of the
cyclotomic field `\QQ(\zeta_n)`, where `d`
Expand Down Expand Up @@ -1265,8 +1266,7 @@ cdef class Pari(Pari_auto):
v = self._empty_vector(n)
if entries is not None:
if len(entries) != n:
raise IndexError("length of entries (=%s) must equal n (=%s)"%\
(len(entries), n))
raise IndexError(f"length of entries (={len(entries)}) must equal n (={n})")
for i, x in enumerate(entries):
v[i] = x
return v
Expand All @@ -1293,22 +1293,22 @@ cdef class Pari(Pari_auto):
cdef Gen x

sig_on()
A = new_gen(zeromatcopy(m,n))
A = new_gen(zeromatcopy(m, n))
if entries is not None:
if len(entries) != m * n:
raise IndexError("len of entries (=%s) must be %s*%s=%s"%(len(entries),m,n,m*n))
raise IndexError("len of entries (=%s) must be %s*%s=%s" % (len(entries), m, n, m*n))
k = 0
for i in range(m):
for j in range(n):
sig_check()
x = objtogen(entries[k])
set_gcoeff(A.g, i+1, j+1, x.ref_target())
A.cache((i,j), x)
A.cache((i, j), x)
k += 1
return A

def genus2red(self, P, p=None):
"""
r"""
Let `P` be a polynomial with integer coefficients.
Determines the reduction of the (proper, smooth) genus 2
curve `C/\QQ`, defined by the hyperelliptic equation `y^2 = P`.
Expand Down
2 changes: 0 additions & 2 deletions cypari2/paridecl.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,6 @@ cdef extern from *: # PARI headers already included by types.pxd
long poliscyclo(GEN f)
long poliscycloprod(GEN f)


# RgV.c

GEN Rg_RgC_sub(GEN a, GEN x)
Expand Down Expand Up @@ -3171,7 +3170,6 @@ cdef extern from *: # PARI headers already included by types.pxd
long z_pval(long n, GEN p)
long z_pvalrem(long n, GEN p, long *py)


# gen3.c

GEN padic_to_Q(GEN x)
Expand Down
2 changes: 1 addition & 1 deletion cypari2/types.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ cdef extern from "pari/pari.h":
t_INFINITY

int BITS_IN_LONG
long DEFAULTPREC # 64 bits precision
long DEFAULTPREC # 64 bits precision
long MEDDEFAULTPREC # 128 bits precision
long BIGDEFAULTPREC # 192 bits precision

Expand Down
Loading