Skip to content

Add public .prec attribute to series #289

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 8 commits into from
Jun 23, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
python-version: '3.13'

- uses: msys2/setup-msys2@v2
- uses: msys2/setup-msys2@v2.27.0
with:
msystem: mingw64
# path-type inherit is used so that when cibuildwheel calls msys2 to
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,14 @@ Next release (0.8.0)...

Contributors

- Oscar Benjamin (OB)
- Robert Dougherty-Bliss (RDB)

Changes

- [gh-289](https://github.com/flintlib/python-flint/pull/289),
Add `.prec` attribute to series types `fmpz_series`, `fmpq_series`,
`arb_series` and `acb_series`. (OB)
- [gh-274](https://github.com/flintlib/python-flint/pull/274),
Add resultant methods to `fmpz_poly`, `fmpq_poly` and
`nmod_poly`. Now all univariate and polynomial types have the
Expand Down
8 changes: 8 additions & 0 deletions src/flint/test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,11 @@ def test_fmpz_series():
s2 = Z([1,2])
s3 = Z([1,1])
s4 = Z([1,2],11)
s5 = Z([1,2],3)
p1 = Zp([1,2])
assert s1.prec == 10
assert s4.prec == 11
assert s5.prec == 3
assert s1._equal_repr(s1) is True
assert s1._equal_repr(s2) is True
assert s1._equal_repr(s3) is False
Expand Down Expand Up @@ -1157,10 +1161,14 @@ def test_fmpq_series():
s2 = Q([1,2])
s3 = Q([1,1])
s4 = Q([1,2],1,11)
s5 = Q([1,2],1,3)
p1 = Qp([1,2])
sz1 = Z([1,2])
sz2 = Z([1,1])
sz3 = Z([1,1],11)
assert s1.prec == 10
assert s4.prec == 11
assert s5.prec == 3
assert s1._equal_repr(s1) is True
assert s1._equal_repr(s2) is True
assert s1._equal_repr(s3) is False
Expand Down
32 changes: 23 additions & 9 deletions src/flint/test/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,48 @@

import flint

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

test_flint_at_least = {
"flint.types._gr.gr_ctx.gens": 30100,
"flint.types._gr.gr_ctx.neg": 30100,
"flint.types.acb_theta.acb_theta": 30300,
}


def find_doctests(module):
finder = doctest.DocTestFinder()
tests = []
tests_seen = set()
for module_info in pkgutil.walk_packages(module.__path__, flint.__name__ + "."):
try:
module = importlib.import_module(module_info.name)

res = []
for test in filter(lambda x: bool(x.examples), finder.find(module)):

m = dunder_test_regex.match(test.name)
if m is not None:
groups = m.groups()
test.name = groups[0] + groups[2]
test.lineno = int(groups[3])

if (
test_flint_at_least.get("".join(groups[:3]), flint.__FLINT_RELEASE__)
<= flint.__FLINT_RELEASE__
):
res.append(test)
test.name = groups[0] + groups[1]
test.lineno = int(groups[2])

# Prefer the __test__ version of the test (remove the other)
if test.name in tests_seen:
n = len(res)
res = [r for r in res if r.name != test.name]
if len(res) != n - 1:
raise Exception(f"Duplicate test name: {test.name}")
tests_seen.remove(test.name)

# Doctests that fail without latest flint
if test.name in test_flint_at_least:
if test_flint_at_least[test.name] > flint.__FLINT_RELEASE__:
continue

if test.name not in tests_seen:
tests_seen.add(test.name)
res.append(test)

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

Expand Down
2 changes: 1 addition & 1 deletion src/flint/types/acb_series.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ from flint.flintlib.functions.acb_poly cimport acb_poly_t

cdef class acb_series(flint_series):
cdef acb_poly_t val
cdef long prec
cdef long _prec
cpdef long length(self)
cpdef valuation(self)
Loading
Loading