Skip to content

fix E701 #205

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

Merged
merged 2 commits into from
Aug 30, 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: 3 additions & 3 deletions src/flint/flintlib/fmpz_mpoly.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ cdef extern from "flint/fmpz_mpoly.h":
void fmpz_mpoly_symmetric_gens(fmpz_mpoly_t res, ulong k, slong * vars, slong n, const fmpz_mpoly_ctx_t ctx)
void fmpz_mpoly_symmetric(fmpz_mpoly_t res, ulong k, const fmpz_mpoly_ctx_t ctx)
# undocumented functions
void _fmpz_mpoly_push_exp_ffmpz(fmpz_mpoly_t A, const fmpz_struct * exp, const fmpz_mpoly_ctx_t ctx);
void _fmpz_mpoly_push_exp_pfmpz(fmpz_mpoly_t A, fmpz_struct * const * exp, const fmpz_mpoly_ctx_t ctx);
void _fmpz_mpoly_push_exp_ui(fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx);
void _fmpz_mpoly_push_exp_ffmpz(fmpz_mpoly_t A, const fmpz_struct * exp, const fmpz_mpoly_ctx_t ctx)
void _fmpz_mpoly_push_exp_pfmpz(fmpz_mpoly_t A, fmpz_struct * const * exp, const fmpz_mpoly_ctx_t ctx)
void _fmpz_mpoly_push_exp_ui(fmpz_mpoly_t A, const ulong * exp, const fmpz_mpoly_ctx_t ctx)

# Macros
fmpz_mpoly_struct *fmpz_mpoly_vec_entry(fmpz_mpoly_vec_t vec, slong i)
2 changes: 1 addition & 1 deletion src/flint/flintlib/fmpz_mpoly_factor.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cdef extern from "flint/fmpz_mpoly_factor.h":
slong num
slong alloc

ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1];
ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1]

void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx)
void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx)
Expand Down
4 changes: 2 additions & 2 deletions src/flint/flintlib/fq_nmod.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ cdef extern from "flint/fq_nmod.h":
void fq_nmod_one(fq_nmod_t rop, const fq_nmod_ctx_t ctx)
void fq_nmod_gen(fq_nmod_t rop, const fq_nmod_ctx_t ctx)
int fq_nmod_get_fmpz(fmpz_t rop, const fq_nmod_t op, const fq_nmod_ctx_t ctx)
void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx);
void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx);
void fq_nmod_get_nmod_poly(nmod_poly_t a, const fq_nmod_t b, const fq_nmod_ctx_t ctx)
void fq_nmod_set_nmod_poly(fq_nmod_t a, const nmod_poly_t b, const fq_nmod_ctx_t ctx)
void fq_nmod_get_nmod_mat(nmod_mat_t col, const fq_nmod_t a, const fq_nmod_ctx_t ctx)
void fq_nmod_set_nmod_mat(fq_nmod_t a, const nmod_mat_t col, const fq_nmod_ctx_t ctx)
int fq_nmod_is_zero(const fq_nmod_t op, const fq_nmod_ctx_t ctx)
Expand Down
48 changes: 32 additions & 16 deletions src/flint/types/acb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ cdef class acb(flint_scalar):
res = acb_eq(s.val, tval)
else:
res = acb_ne(s.val, tval)
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return res

def __contains__(self, other):
Expand Down Expand Up @@ -402,7 +403,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_add((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __radd__(s, t):
Expand All @@ -413,7 +415,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_add((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __sub__(s, t):
Expand All @@ -424,7 +427,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_sub((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __rsub__(s, t):
Expand All @@ -435,7 +439,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_sub((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __mul__(s, t):
Expand All @@ -446,7 +451,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_mul((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __rmul__(s, t):
Expand All @@ -457,7 +463,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_mul((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __truediv__(s, t):
Expand All @@ -468,7 +475,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_div((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __rtruediv__(s, t):
Expand All @@ -479,7 +487,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_div((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __pow__(s, t, u):
Expand All @@ -492,7 +501,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_pow((<acb>u).val, (<acb>s).val, tval, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def __rpow__(s, t, u):
Expand All @@ -505,7 +515,8 @@ cdef class acb(flint_scalar):
return NotImplemented
u = acb.__new__(acb)
acb_pow((<acb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: acb_clear(tval)
if ttype == FMPZ_TMP:
acb_clear(tval)
return u

def union(s, t):
Expand Down Expand Up @@ -1535,11 +1546,16 @@ cdef class acb(flint_scalar):
c = any_as_acb(c)
u = acb.__new__(acb)
flags = 0
if regularized: flags |= 1
if ab: flags |= 2
if ac: flags |= 4
if bc: flags |= 8
if abc: flags |= 16
if regularized:
flags |= 1
if ab:
flags |= 2
if ac:
flags |= 4
if bc:
flags |= 8
if abc:
flags |= 16
acb_hypgeom_2f1((<acb>u).val, (<acb>a).val, (<acb>b).val, (<acb>c).val,
(<acb>self).val, flags, getprec())
return u
Expand Down
69 changes: 46 additions & 23 deletions src/flint/types/arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,22 @@ cdef class arb(flint_scalar):
if ttype == FMPZ_UNKNOWN:
return NotImplemented
res = 0
if op == 2: res = arb_eq(sval, tval)
elif op == 3: res = arb_ne(sval, tval)
elif op == 0: res = arb_lt(sval, tval)
elif op == 1: res = arb_le(sval, tval)
elif op == 4: res = arb_gt(sval, tval)
elif op == 5: res = arb_ge(sval, tval)
if stype == FMPZ_TMP: arb_clear(sval)
if ttype == FMPZ_TMP: arb_clear(tval)
if op == 2:
res = arb_eq(sval, tval)
elif op == 3:
res = arb_ne(sval, tval)
elif op == 0:
res = arb_lt(sval, tval)
elif op == 1:
res = arb_le(sval, tval)
elif op == 4:
res = arb_gt(sval, tval)
elif op == 5:
res = arb_ge(sval, tval)
if stype == FMPZ_TMP:
arb_clear(sval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return res

def __contains__(self, other):
Expand Down Expand Up @@ -563,7 +571,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_add((<arb>u).val, (<arb>s).val, tval, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __radd__(s, t):
Expand All @@ -574,7 +583,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_add((<arb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __sub__(s, t):
Expand All @@ -585,7 +595,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_sub((<arb>u).val, (<arb>s).val, tval, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __rsub__(s, t):
Expand All @@ -596,7 +607,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_sub((<arb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __mul__(s, t):
Expand All @@ -607,7 +619,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_mul((<arb>u).val, (<arb>s).val, tval, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __rmul__(s, t):
Expand All @@ -618,7 +631,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_mul((<arb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __truediv__(s, t):
Expand All @@ -629,7 +643,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_div((<arb>u).val, (<arb>s).val, tval, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __rtruediv__(s, t):
Expand All @@ -640,7 +655,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_div((<arb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __pow__(s, t, modulus):
Expand All @@ -653,7 +669,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_pow((<arb>u).val, (<arb>s).val, tval, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def __rpow__(s, t, modulus):
Expand All @@ -666,7 +683,8 @@ cdef class arb(flint_scalar):
return NotImplemented
u = arb.__new__(arb)
arb_pow((<arb>u).val, tval, s.val, getprec())
if ttype == FMPZ_TMP: arb_clear(tval)
if ttype == FMPZ_TMP:
arb_clear(tval)
return u

def floor(s):
Expand Down Expand Up @@ -2252,11 +2270,16 @@ cdef class arb(flint_scalar):
c = any_as_arb(c)
u = arb.__new__(arb)
flags = 0
if regularized: flags |= 1
if ab: flags |= 2
if ac: flags |= 4
if bc: flags |= 8
if abc: flags |= 16
if regularized:
flags |= 1
if ab:
flags |= 2
if ac:
flags |= 4
if bc:
flags |= 8
if abc:
flags |= 16
arb_hypgeom_2f1((<arb>u).val, (<arb>a).val, (<arb>b).val, (<arb>c).val,
(<arb>self).val, flags, getprec())
return u
Expand Down
18 changes: 12 additions & 6 deletions src/flint/types/arf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,18 @@ cdef class arf:
cdef bint res = 0
if not typecheck(t, arf):
t = arf(t)
if op == 2: res = arf_equal((<arf>s).val, (<arf>t).val)
elif op == 3: res = not arf_equal((<arf>s).val, (<arf>t).val)
elif op == 0: res = arf_cmp((<arf>s).val, (<arf>t).val) < 0
elif op == 1: res = arf_cmp((<arf>s).val, (<arf>t).val) <= 0
elif op == 4: res = arf_cmp((<arf>s).val, (<arf>t).val) > 0
elif op == 5: res = arf_cmp((<arf>s).val, (<arf>t).val) >= 0
if op == 2:
res = arf_equal((<arf>s).val, (<arf>t).val)
elif op == 3:
res = not arf_equal((<arf>s).val, (<arf>t).val)
elif op == 0:
res = arf_cmp((<arf>s).val, (<arf>t).val) < 0
elif op == 1:
res = arf_cmp((<arf>s).val, (<arf>t).val) <= 0
elif op == 4:
res = arf_cmp((<arf>s).val, (<arf>t).val) > 0
elif op == 5:
res = arf_cmp((<arf>s).val, (<arf>t).val) >= 0
return res

def __pos__(self):
Expand Down
21 changes: 14 additions & 7 deletions src/flint/types/fmpq.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,16 @@ cdef class fmpq(flint_scalar):
return res
else:
# todo: use fmpq_cmp when available
if op == 0: res = (s-t).p < 0
elif op == 1: res = (s-t).p <= 0
elif op == 4: res = (s-t).p > 0
elif op == 5: res = (s-t).p >= 0
else: raise ValueError
if op == 0:
res = (s-t).p < 0
elif op == 1:
res = (s-t).p <= 0
elif op == 4:
res = (s-t).p > 0
elif op == 5:
res = (s-t).p >= 0
else:
raise ValueError
return res

def numer(self):
Expand Down Expand Up @@ -474,13 +479,15 @@ cdef class fmpq(flint_scalar):
return NotImplemented

if fmpq_is_zero((<fmpq>self).val) and fmpz_sgn(nval) == -1:
if ntype == FMPZ_TMP: fmpz_clear(nval)
if ntype == FMPZ_TMP:
fmpz_clear(nval)
raise ZeroDivisionError

v = fmpq.__new__(fmpq)
success = fmpq_pow_fmpz(v.val, (<fmpq>self).val, nval)

if ntype == FMPZ_TMP: fmpz_clear(nval)
if ntype == FMPZ_TMP:
fmpz_clear(nval)

if success:
return v
Expand Down
Loading
Loading