Skip to content

Commit 5a7de35

Browse files
committed
Merge remote-tracking branch 'origin/master' into fmpz_mod_mpoly_and_nmod_mpoly
2 parents 805fd34 + 591f900 commit 5a7de35

21 files changed

Lines changed: 152 additions & 49 deletions

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,16 @@ CHANGELOG
133133

134134
Next release:
135135

136+
- [gh-161](https://github.com/flintlib/python-flint/pull/161)
137+
Add `acb.lerch_phi` to compute the Lerch transcendent.
136138
- [gh-132](https://github.com/flintlib/python-flint/pull/132)
137139
Add `fmpz_mpoly` and `fmpq_mpoly` types for multivariate polynomials with
138140
integer or rational coefficients.
139141
- [gh-160](https://github.com/flintlib/python-flint/pull/160)
140142
Add `bits` to `arb` and `acb`, add `log_base` to `arb`.
143+
- [gh-149](https://github.com/flintlib/python-flint/pull/149)
144+
Bump Flint version to 3.1.3-p1 (Flint 3.0.0 - 3.1.3-p1 is supported but the
145+
wheels are built with 3.1.3-p1).
141146
- [gh-148](https://github.com/flintlib/python-flint/pull/148)
142147
Remove debug symbols to make smaller Linux binaries.
143148
- [gh-144](https://github.com/flintlib/python-flint/pull/144)
@@ -150,9 +155,6 @@ Next release:
150155
Add `erfinv` and `erfcinv` for `arb`.
151156
- [gh-129](https://github.com/flintlib/python-flint/pull/129)
152157
Use meson-python instead of setuptools as the build backend.
153-
- [gh-125](https://github.com/flintlib/python-flint/pull/125)
154-
Bump Flint version to 3.1.2 (Flint 3.0.0 - 3.1.2 is supported but the wheels
155-
are built with 3.1.2).
156158

157159
0.6.0
158160

bin/build_dependencies_unix.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ else
257257
tar xf mpfr-$MPFRVER.tar.gz
258258
cd mpfr-$MPFRVER
259259
./configure --prefix=$PREFIX\
260+
--host=$HOST_ARG\
260261
--with-gmp=$PREFIX\
261262
--enable-shared=yes\
262263
--enable-static=no
@@ -281,7 +282,13 @@ curl -O -L https://github.com/flintlib/flint/releases/download/v$FLINTVER/flint-
281282
tar xf flint-$FLINTVER.tar.gz
282283
cd flint-$FLINTVER
283284
./bootstrap.sh
285+
# --host=$HOST_ARG\ # host is ignored
286+
# --enable-arch works on 3.1.3p1, not available on HEAD
284287
./configure --prefix=$PREFIX\
288+
--enable-arch=${HOST_ARG%%-*}\
289+
--disable-assembly\
290+
--disable-avx2\
291+
--disable-avx512\
285292
$FLINTARB_WITHGMP\
286293
--with-mpfr=$PREFIX\
287294
--disable-static\

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
# built documents.
5252
#
5353
# The short X.Y version.
54-
version = '0.7.0a3'
54+
version = '0.7.0a4'
5555
# The full version, including alpha/beta/rc tags.
56-
release = '0.7.0a3'
56+
release = '0.7.0a4'
5757

5858
# The language for content autogenerated by Sphinx. Refer to documentation
5959
# for a list of supported languages.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "mesonpy"
55
[project]
66
name = "python-flint"
77
description = "Bindings for FLINT and Arb"
8-
version = "0.7.0a3"
8+
version = "0.7.0a4"
99
urls = {Homepage = "https://github.com/flintlib/python-flint"}
1010
authors = [
1111
{name = "Fredrik Johansson", email = "fredrik.johansson@gmail.com"},

src/flint/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
Ordering,
4646
)
4747

48-
__version__ = '0.7.0a3'
48+
__version__ = '0.7.0a4'

src/flint/test/test_all.py

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def raises(f, exception):
3232

3333
def test_pyflint():
3434

35-
assert flint.__version__ == "0.7.0a3"
35+
assert flint.__version__ == "0.7.0a4"
3636

3737
ctx = flint.ctx
3838
assert str(ctx) == repr(ctx) == _default_ctx_string
@@ -1604,7 +1604,7 @@ def test_pickling():
16041604

16051605
def test_fmpz_mod():
16061606
from flint import fmpz_mod_ctx, fmpz, fmpz_mod
1607-
1607+
16081608
p_sml = 163
16091609
p_med = 2**127 - 1
16101610
p_big = 2**255 - 19
@@ -1754,7 +1754,7 @@ def test_fmpz_mod():
17541754
assert raises(lambda: F_test(test_x) * "AAA", TypeError)
17551755
assert raises(lambda: F_test(test_x) * F_other(test_x), ValueError)
17561756

1757-
# Exponentiation
1757+
# Exponentiation
17581758

17591759
assert F_test(0)**0 == pow(0, 0, test_mod)
17601760
assert F_test(0)**1 == pow(0, 1, test_mod)
@@ -1804,7 +1804,7 @@ def test_fmpz_mod():
18041804

18051805
assert fmpz(test_y) / F_test(test_x) == (test_y * pow(test_x, -1, test_mod)) % test_mod
18061806
assert test_y / F_test(test_x) == (test_y * pow(test_x, -1, test_mod)) % test_mod
1807-
1807+
18081808
def test_fmpz_mod_dlog():
18091809
from flint import fmpz, fmpz_mod_ctx
18101810

@@ -1826,7 +1826,7 @@ def test_fmpz_mod_dlog():
18261826
F = fmpz_mod_ctx(163)
18271827
g = F(2)
18281828
a = g**123
1829-
1829+
18301830
assert 123 == g.discrete_log(a)
18311831

18321832
a_int = pow(2, 123, 163)
@@ -1877,7 +1877,7 @@ def test_fmpz_mod_poly():
18771877
assert repr(R3) == "fmpz_mod_poly_ctx(13)"
18781878

18791879
assert R1.modulus() == 11
1880-
1880+
18811881
assert R1.is_prime()
18821882
assert R1.zero() == 0
18831883
assert R1.one() == 1
@@ -1946,7 +1946,7 @@ def test_fmpz_mod_poly():
19461946
assert str(f) == "8*x^3 + 7*x^2 + 6*x + 7"
19471947

19481948
# TODO: currently repr does pretty printing
1949-
# just like str, we should address this. Mainly,
1949+
# just like str, we should address this. Mainly,
19501950
# the issue is we want nice `repr` behaviour in
19511951
# interactive shells, which currently is why this
19521952
# choice has been made
@@ -1992,7 +1992,7 @@ def test_fmpz_mod_poly():
19921992
F_sml = fmpz_mod_ctx(p_sml)
19931993
F_med = fmpz_mod_ctx(p_med)
19941994
F_big = fmpz_mod_ctx(p_big)
1995-
1995+
19961996
R_sml = fmpz_mod_poly_ctx(F_sml)
19971997
R_med = fmpz_mod_poly_ctx(F_med)
19981998
R_big = fmpz_mod_poly_ctx(F_big)
@@ -2003,14 +2003,14 @@ def test_fmpz_mod_poly():
20032003
f_bad = R_cmp([2,2,2,2,2])
20042004

20052005
for (F_test, R_test) in [(F_sml, R_sml), (F_med, R_med), (F_big, R_big)]:
2006-
2006+
20072007
f = R_test([-1,-2])
20082008
g = R_test([-3,-4])
20092009

20102010
# pos, neg
20112011
assert f is +f
20122012
assert -f == R_test([1,2])
2013-
2013+
20142014
# add
20152015
assert raises(lambda: f + f_cmp, ValueError)
20162016
assert raises(lambda: f + "AAA", TypeError)
@@ -2063,7 +2063,7 @@ def test_fmpz_mod_poly():
20632063
assert raises(lambda: f / "AAA", TypeError)
20642064
assert raises(lambda: f / 0, ZeroDivisionError)
20652065
assert raises(lambda: f_cmp / 2, ZeroDivisionError)
2066-
2066+
20672067
assert (f + f) / 2 == f
20682068
assert (f + f) / fmpz(2) == f
20692069
assert (f + f) / F_test(2) == f
@@ -2077,7 +2077,7 @@ def test_fmpz_mod_poly():
20772077
assert (f + f) // 2 == f
20782078
assert (f + f) // fmpz(2) == f
20792079
assert (f + f) // F_test(2) == f
2080-
assert 2 // R_test(2) == 1
2080+
assert 2 // R_test(2) == 1
20812081
assert (f + 1) // f == 1
20822082

20832083
# pow
@@ -2171,7 +2171,7 @@ def test_fmpz_mod_poly():
21712171
f1 = R_test([-3, 1])
21722172
f2 = R_test([-5, 1])
21732173
assert f1.resultant(f2) == (3 - 5)
2174-
assert raises(lambda: f.resultant("AAA"), TypeError)
2174+
assert raises(lambda: f.resultant("AAA"), TypeError)
21752175

21762176
# sqrt
21772177
f1 = R_test.random_element(irreducible=True)
@@ -2428,14 +2428,14 @@ def _all_polys():
24282428
(flint.fmpz_poly, flint.fmpz, False),
24292429
(flint.fmpq_poly, flint.fmpq, True),
24302430
(lambda *a: flint.nmod_poly(*a, 17), lambda x: flint.nmod(x, 17), True),
2431-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(163)),
2432-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(163)),
2431+
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(163)),
2432+
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(163)),
24332433
True),
2434-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**127 - 1)),
2435-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**127 - 1)),
2434+
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**127 - 1)),
2435+
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**127 - 1)),
24362436
True),
2437-
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**255 - 19)),
2438-
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**255 - 19)),
2437+
(lambda *a: flint.fmpz_mod_poly(*a, flint.fmpz_mod_poly_ctx(2**255 - 19)),
2438+
lambda x: flint.fmpz_mod(x, flint.fmpz_mod_ctx(2**255 - 19)),
24392439
True),
24402440
]
24412441

@@ -2467,6 +2467,28 @@ def test_polys():
24672467
assert (P([1]) == P([2])) is False
24682468
assert (P([1]) != P([2])) is True
24692469

2470+
assert (P([1]) == 1) is True
2471+
assert (P([1]) != 1) is False
2472+
assert (P([1]) == 2) is False
2473+
assert (P([1]) != 2) is True
2474+
2475+
assert (1 == P([1])) is True
2476+
assert (1 != P([1])) is False
2477+
assert (2 == P([1])) is False
2478+
assert (2 != P([1])) is True
2479+
2480+
s1, s2 = S(1), S(2)
2481+
2482+
assert (P([s1]) == s1) is True
2483+
assert (P([s1]) != s1) is False
2484+
assert (P([s1]) == s2) is False
2485+
assert (P([s1]) != s2) is True
2486+
2487+
assert (s1 == P([s1])) is True
2488+
assert (s1 != P([s1])) is False
2489+
assert (s1 == P([s2])) is False
2490+
assert (s1 != P([s2])) is True
2491+
24702492
assert (P([1]) == None) is False
24712493
assert (P([1]) != None) is True
24722494
assert (None == P([1])) is False
@@ -2500,12 +2522,17 @@ def setbad(obj, i, val):
25002522
assert raises(lambda: setbad(p, -1, 1), ValueError)
25012523

25022524
for v in [], [1], [1, 2]:
2503-
if P == flint.fmpz_poly:
2525+
p = P(v)
2526+
if type(p) == flint.fmpz_poly:
25042527
assert P(v).repr() == f'fmpz_poly({v!r})'
2505-
elif P == flint.fmpq_poly:
2528+
elif type(p) == flint.fmpq_poly:
25062529
assert P(v).repr() == f'fmpq_poly({v!r})'
2507-
elif P == flint.nmod_poly:
2530+
elif type(p) == flint.nmod_poly:
25082531
assert P(v).repr() == f'nmod_poly({v!r}, 17)'
2532+
elif type(p) == flint.fmpz_mod_poly:
2533+
pass # fmpz_mod_poly does not have .repr() ...
2534+
else:
2535+
assert False
25092536

25102537
assert repr(P([])) == '0'
25112538
assert repr(P([1])) == '1'
@@ -2521,6 +2548,12 @@ def setbad(obj, i, val):
25212548
assert bool(P([])) is False
25222549
assert bool(P([1])) is True
25232550

2551+
assert P([]).is_zero() is True
2552+
assert P([1]).is_zero() is False
2553+
2554+
assert P([]).is_one() is False
2555+
assert P([1]).is_one() is True
2556+
25242557
assert +P([1, 2, 3]) == P([1, 2, 3])
25252558
assert -P([1, 2, 3]) == P([-1, -2, -3])
25262559

@@ -2600,7 +2633,7 @@ def setbad(obj, i, val):
26002633
assert P([1, 1]) ** 2 == P([1, 2, 1])
26012634
assert raises(lambda: P([1, 1]) ** -1, ValueError)
26022635
assert raises(lambda: P([1, 1]) ** None, TypeError)
2603-
2636+
26042637
# # XXX: Not sure what this should do in general:
26052638
assert raises(lambda: pow(P([1, 1]), 2, 3), NotImplementedError)
26062639

@@ -2852,6 +2885,12 @@ def quick_poly():
28522885
assert bool(P(ctx=ctx)) is False
28532886
assert bool(P(1, ctx=ctx)) is True
28542887

2888+
assert P(ctx=ctx).is_zero() is True
2889+
assert P(1, ctx=ctx).is_zero() is False
2890+
2891+
assert P(ctx=ctx).is_one() is False
2892+
assert P(1, ctx=ctx).is_one() is True
2893+
28552894
assert +quick_poly() \
28562895
== quick_poly()
28572896

src/flint/types/acb.pyx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,21 @@ cdef class acb(flint_scalar):
733733
acb_hurwitz_zeta((<acb>u).val, (<acb>s).val, (<acb>a).val, getprec())
734734
return u
735735

736+
def lerch_phi(z, s, a):
737+
"""
738+
Lerch transcendent `\Phi(z,s,a)`.
739+
740+
>>> from flint import showgood
741+
>>> showgood(lambda: acb(1,2).lerch_phi(3, 4), dps=25)
742+
0.006872751459699249251487346 + 0.01112535314686351879432212j
743+
"""
744+
s = any_as_acb(s)
745+
a = any_as_acb(a)
746+
u = acb.__new__(acb)
747+
acb_dirichlet_lerch_phi((<acb>u).val, (<acb>z).val, (<acb>s).val, (<acb>a).val, getprec())
748+
return u
749+
750+
736751
def dirichlet_l(s, chi):
737752
cdef dirichlet_char cchar
738753
if isinstance(chi, dirichlet_char):

src/flint/types/acb_mat.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ cdef class acb_mat(flint_mat):
150150
else:
151151
raise ValueError("acb_mat: expected 1-3 arguments")
152152

153-
def __nonzero__(self):
153+
def __bool__(self):
154154
raise NotImplementedError
155155

156156
cpdef long nrows(s):

src/flint/types/arb_mat.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ cdef class arb_mat(flint_mat):
148148
else:
149149
raise ValueError("arb_mat: expected 1-3 arguments")
150150

151-
def __nonzero__(self):
151+
def __bool__(self):
152152
raise NotImplementedError
153153

154154
cpdef long nrows(s):

src/flint/types/fmpq.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ cdef class fmpq(flint_scalar):
186186
def __trunc__(self):
187187
return self.trunc()
188188

189-
def __nonzero__(self):
189+
def __bool__(self):
190190
return not fmpq_is_zero(self.val)
191191

192192
def __round__(self, ndigits=None):

0 commit comments

Comments
 (0)