Skip to content

Commit d3fdee3

Browse files
committed
Add .prec attribute to series
Adds .prec attribute to fmpz_series, fmpq_series, arb_series and acb_series. Also fixes the doctest runner to run all tests and fixes some doctests. Make sure that doctests use the correct precision.
1 parent 9a853c4 commit d3fdee3

18 files changed

+680
-450
lines changed

src/flint/test/test_all.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,11 @@ def test_fmpz_series():
666666
s2 = Z([1,2])
667667
s3 = Z([1,1])
668668
s4 = Z([1,2],11)
669+
s5 = Z([1,2],3)
669670
p1 = Zp([1,2])
671+
assert s1.prec == 10
672+
assert s4.prec == 11
673+
assert s5.prec == 3
670674
assert s1._equal_repr(s1) is True
671675
assert s1._equal_repr(s2) is True
672676
assert s1._equal_repr(s3) is False
@@ -1157,10 +1161,14 @@ def test_fmpq_series():
11571161
s2 = Q([1,2])
11581162
s3 = Q([1,1])
11591163
s4 = Q([1,2],1,11)
1164+
s5 = Q([1,2],1,3)
11601165
p1 = Qp([1,2])
11611166
sz1 = Z([1,2])
11621167
sz2 = Z([1,1])
11631168
sz3 = Z([1,1],11)
1169+
assert s1.prec == 10
1170+
assert s4.prec == 11
1171+
assert s5.prec == 3
11641172
assert s1._equal_repr(s1) is True
11651173
assert s1._equal_repr(s2) is True
11661174
assert s1._equal_repr(s3) is False

src/flint/test/test_docstrings.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import flint
77

8-
dunder_test_regex = re.compile(r'^(.*?)__test__\.(.*?\.)(.*) \(line (\d+)\)$')
8+
dunder_test_regex = re.compile(r'^(.*?)__test__\.(.*?) \(line (\d+)\)$')
99

1010
test_flint_at_least = {
1111
"flint.types._gr.gr_ctx.gens": 30100,
@@ -16,23 +16,36 @@
1616
def find_doctests(module):
1717
finder = doctest.DocTestFinder()
1818
tests = []
19+
tests_seen = set()
1920
for module_info in pkgutil.walk_packages(module.__path__, flint.__name__ + "."):
2021
try:
2122
module = importlib.import_module(module_info.name)
2223

2324
res = []
2425
for test in filter(lambda x: bool(x.examples), finder.find(module)):
26+
2527
m = dunder_test_regex.match(test.name)
2628
if m is not None:
2729
groups = m.groups()
28-
test.name = groups[0] + groups[2]
29-
test.lineno = int(groups[3])
30-
31-
if (
32-
test_flint_at_least.get("".join(groups[:3]), flint.__FLINT_RELEASE__)
33-
<= flint.__FLINT_RELEASE__
34-
):
35-
res.append(test)
30+
test.name = groups[0] + groups[1]
31+
test.lineno = int(groups[2])
32+
33+
# Prefer the __test__ version of the test (remove the other)
34+
if test.name in tests_seen:
35+
n = len(res)
36+
res = [r for r in res if r.name != test.name]
37+
if len(res) != n - 1:
38+
raise Exception(f"Duplicate test name: {test.name}")
39+
tests_seen.remove(test.name)
40+
41+
# Doctests that fail without latest flint
42+
if test.name in test_flint_at_least:
43+
if test_flint_at_least[test.name] > flint.__FLINT_RELEASE__:
44+
continue
45+
46+
if test.name not in tests_seen:
47+
tests_seen.add(test.name)
48+
res.append(test)
3649

3750
tests.append((module_info.name, res))
3851

src/flint/types/acb_series.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ from flint.flintlib.functions.acb_poly cimport acb_poly_t
44

55
cdef class acb_series(flint_series):
66
cdef acb_poly_t val
7-
cdef long prec
7+
cdef long _prec
88
cpdef long length(self)
99
cpdef valuation(self)

0 commit comments

Comments
 (0)