Skip to content

Commit 47e4ba9

Browse files
Merge pull request #289 from oscarbenjamin/pr_prec
Add public .prec attribute to series
2 parents 9a853c4 + 7d6f96f commit 47e4ba9

20 files changed

+685
-451
lines changed

.github/workflows/buildwheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
python-version: '3.13'
2121

22-
- uses: msys2/setup-msys2@v2
22+
- uses: msys2/setup-msys2@v2.27.0
2323
with:
2424
msystem: mingw64
2525
# path-type inherit is used so that when cibuildwheel calls msys2 to

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,14 @@ Next release (0.8.0)...
164164

165165
Contributors
166166

167+
- Oscar Benjamin (OB)
167168
- Robert Dougherty-Bliss (RDB)
168169

169170
Changes
170171

172+
- [gh-289](https://github.com/flintlib/python-flint/pull/289),
173+
Add `.prec` attribute to series types `fmpz_series`, `fmpq_series`,
174+
`arb_series` and `acb_series`. (OB)
171175
- [gh-274](https://github.com/flintlib/python-flint/pull/274),
172176
Add resultant methods to `fmpz_poly`, `fmpq_poly` and
173177
`nmod_poly`. Now all univariate and polynomial types have the

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: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,48 @@
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,
1212
"flint.types._gr.gr_ctx.neg": 30100,
13+
"flint.types.acb_theta.acb_theta": 30300,
1314
}
1415

1516

1617
def find_doctests(module):
1718
finder = doctest.DocTestFinder()
1819
tests = []
20+
tests_seen = set()
1921
for module_info in pkgutil.walk_packages(module.__path__, flint.__name__ + "."):
2022
try:
2123
module = importlib.import_module(module_info.name)
2224

2325
res = []
2426
for test in filter(lambda x: bool(x.examples), finder.find(module)):
27+
2528
m = dunder_test_regex.match(test.name)
2629
if m is not None:
2730
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)
31+
test.name = groups[0] + groups[1]
32+
test.lineno = int(groups[2])
33+
34+
# Prefer the __test__ version of the test (remove the other)
35+
if test.name in tests_seen:
36+
n = len(res)
37+
res = [r for r in res if r.name != test.name]
38+
if len(res) != n - 1:
39+
raise Exception(f"Duplicate test name: {test.name}")
40+
tests_seen.remove(test.name)
41+
42+
# Doctests that fail without latest flint
43+
if test.name in test_flint_at_least:
44+
if test_flint_at_least[test.name] > flint.__FLINT_RELEASE__:
45+
continue
46+
47+
if test.name not in tests_seen:
48+
tests_seen.add(test.name)
49+
res.append(test)
3650

3751
tests.append((module_info.name, res))
3852

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)