Skip to content
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

fix: make test suite run doctests #31

Merged
merged 3 commits into from
Dec 13, 2022
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
22 changes: 22 additions & 0 deletions .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,25 @@ jobs:
path: wheelhouse
- run: pip install --find-links wheelhouse python_flint
- run: python test/test.py

doctest_wheels:
needs: build_wheels
name: Doctests for ${{ matrix.python-version }} wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v3
with:
name: artifact
path: wheelhouse
- run: pip install --find-links wheelhouse python_flint
- run: python test/dtest.py
7 changes: 7 additions & 0 deletions bin/build_dependencies_unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ cd arb-$ARBVER
--disable-static
make -j3
make install
#
# Here make check passes for Linux and OSX but fails for Windows probably
# because of a linker error or something like that. It would be nice to
# enable this check when it can work for Windows but for now we disable it
# because if it fails then we don't get any wheels built.
#
# ARB_TEST_MULTIPLIER=0.1 make check
cd ..

# ------------------------------------------------------------------------- #
Expand Down
2 changes: 1 addition & 1 deletion src/flint/acb_mat.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ cdef class acb_mat(flint_mat):
>>> sum(acb_mat(arb_mat.hilbert(20,20)).eig(nonstop=True))
nan + nanj
>>> showgood(lambda: sum(acb_mat(arb_mat.hilbert(20,20)).eig(nonstop=True)), parts=False)
2.47967321036454 + [+/- 1.48e-56]j
2.47967321036454 + 0e-55j

With default options, the method only succeeds if all eigenvalues can be
isolated. Multiple (overlapping) eigenvalues can be handled by
Expand Down
8 changes: 4 additions & 4 deletions src/flint/arb_mat.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ cdef class arb_mat(flint_mat):
magnitude have been replaced by exact zeros.

>>> print(arb_mat.stirling(4, 4).inv().str(5, radius=False))
[1.0000, 0, 0, 0]
[ 0, 1.0000, [+/- 1.20e-15], [+/- 5.00e-16]]
[ 0, -1.0000, 1.0000, [+/- 1.67e-16]]
[ 0, 1.0000, -3.0000, 1.0000]
[1.0000, 0, 0, 0]
[ 0, 1.0000, 0e-14, 0e-15]
[ 0, -1.0000, 1.0000, 0e-15]
[ 0, 1.0000, -3.0000, 1.0000]
>>> print(arb_mat.stirling(4, 4).inv().chop(1e-6).str(5, radius=False))
[1.0000, 0, 0, 0]
[ 0, 1.0000, 0, 0]
Expand Down
10 changes: 10 additions & 0 deletions test/dtest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys
import doctest
import flint

sys.stdout.write("doctests...");
fail, total = doctest.testmod(flint._flint);
if fail == 0:
print("OK")
else:
raise AssertionError("%i of %i doctests failed" % (fail, total))
17 changes: 11 additions & 6 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,14 @@ def test_arb():
sys.stdout.write("test_nmod_poly..."); test_nmod_poly(); print("OK")
sys.stdout.write("test_nmod_mat..."); test_nmod_mat(); print("OK")
sys.stdout.write("test_arb.."); test_arb(); print("OK")
sys.stdout.write("doctests...");
fail, total = doctest.testmod(flint);
if fail == 0:
print("OK")
else:
raise AssertionError("%i of %i doctests failed" % (fail, total))
print("OK")
#
# The doctests currently fail on Windows so for now we separate them into a
# separate test/doctest.py.
#
#sys.stdout.write("doctests...");
#fail, total = doctest.testmod(flint._flint);
#if fail == 0:
# print("OK")
#else:
# raise AssertionError("%i of %i doctests failed" % (fail, total))