From be48d36c3ef7d6be199556714ec685a8abbf8f31 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Wed, 1 Nov 2023 19:05:14 +0000 Subject: [PATCH 1/5] Export good and ensure all tests run --- .github/workflows/buildwheel.yml | 22 ++++++++++++++++++++++ src/flint/__init__.py | 2 +- src/flint/test/test.py | 12 +++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 35f41f9d..ff6956d5 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -75,6 +75,28 @@ jobs: with: path: dist/*.tar.gz + test_wheels: + needs: build_wheels + name: Test ${{ 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', '3.12'] + + steps: + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/download-artifact@v3 + with: + name: artifact + path: wheelhouse + - run: pip install --no-index --find-links wheelhouse python_flint + - run: pip install pytest + - run: pytest --doctest-glob='*.rst' doc/source + test_wheels: needs: build_wheels name: Test ${{ matrix.python-version }} wheel on ${{ matrix.os }} diff --git a/src/flint/__init__.py b/src/flint/__init__.py index de90e314..bda516f9 100644 --- a/src/flint/__init__.py +++ b/src/flint/__init__.py @@ -24,6 +24,6 @@ from .types.fmpz_mod import * from .types.fmpz_mod_poly import * from .types.dirichlet import * -from .functions.showgood import showgood +from .functions.showgood import good, showgood __version__ = '0.5.0' diff --git a/src/flint/test/test.py b/src/flint/test/test.py index 2d82e821..40c60a7e 100644 --- a/src/flint/test/test.py +++ b/src/flint/test/test.py @@ -78,6 +78,9 @@ def test_pyflint(): assert raises(lambda: setattr(ctx, "prec", -1), ValueError) assert raises(lambda: setattr(ctx, "dps", -1), ValueError) +def test_showgood(): + from flint import good, showgood + def test_fmpz(): assert flint.fmpz() == flint.fmpz(0) L = [0, 1, 2, 3, 2**31-1, 2**31, 2**63-1, 2**63, 2**64-1, 2**64] @@ -2422,10 +2425,14 @@ def setbad(obj, i, val): if is_field: assert P([1, 2, 1]).integral() == P([0, 1, 1, S(1)/3]) - +def test_all_tests(): + test_funcs = {f for name, f in globals().items() if name.startswith("test_")} + untested = test_funcs - set(all_tests) + assert not untested, f"Untested functions: {untested}" all_tests = [ test_pyflint, + test_showgood, test_fmpz, test_fmpz_factor, test_fmpz_functions, @@ -2441,9 +2448,12 @@ def setbad(obj, i, val): test_nmod, test_nmod_poly, test_nmod_mat, + test_nmod_series, test_arb, test_fmpz_mod, test_fmpz_mod_dlog, test_fmpz_mod_poly, test_polys, + test_pickling, + test_all_tests, ] From 991e6c473ed20fd3df07a30b9eadc91185e1448f Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Wed, 1 Nov 2023 19:07:19 +0000 Subject: [PATCH 2/5] Fix CI yml file --- .github/workflows/buildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index ff6956d5..54600fa0 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -97,7 +97,7 @@ jobs: - run: pip install pytest - run: pytest --doctest-glob='*.rst' doc/source - test_wheels: + rst_doctest: needs: build_wheels name: Test ${{ matrix.python-version }} wheel on ${{ matrix.os }} runs-on: ${{ matrix.os }} From a6f975520c5c7f84e8cb62b62343a5eb71b123c9 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Wed, 1 Nov 2023 21:39:03 +0000 Subject: [PATCH 3/5] Merge test jobs --- .github/workflows/buildwheel.yml | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 54600fa0..c84033fe 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -93,30 +93,10 @@ jobs: with: name: artifact path: wheelhouse - - run: pip install --no-index --find-links wheelhouse python_flint - run: pip install pytest - - run: pytest --doctest-glob='*.rst' doc/source - - rst_doctest: - needs: build_wheels - name: Test ${{ 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', '3.12'] - - steps: - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/download-artifact@v3 - with: - name: artifact - path: wheelhouse - run: pip install --no-index --find-links wheelhouse python_flint - run: python -m flint.test --verbose + - run: pytest --doctest-glob='*.rst' doc/source test_pip_vcs_sdist: name: pip install ${{ matrix.target }} on ${{ matrix.python-version }} From e31ff6514c553fb3ed01a1793326a1bf8e4f10b8 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Wed, 1 Nov 2023 22:32:52 +0000 Subject: [PATCH 4/5] Add separate rst doctest job --- .github/workflows/buildwheel.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index c84033fe..64252e59 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -75,6 +75,28 @@ jobs: with: path: dist/*.tar.gz + test_rst: + needs: build_wheels + name: Test rst docs + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - uses: actions/download-artifact@v3 + with: + name: artifact + path: wheelhouse + + - run: pip install --upgrade pip + - run: pip install pytest + - run: pip install --no-index --find-links wheelhouse python_flint + - run: pytest --doctest-glob='*.rst' doc/source + test_wheels: needs: build_wheels name: Test ${{ matrix.python-version }} wheel on ${{ matrix.os }} @@ -93,10 +115,8 @@ jobs: with: name: artifact path: wheelhouse - - run: pip install pytest - run: pip install --no-index --find-links wheelhouse python_flint - run: python -m flint.test --verbose - - run: pytest --doctest-glob='*.rst' doc/source test_pip_vcs_sdist: name: pip install ${{ matrix.target }} on ${{ matrix.python-version }} From 5333f75d0e09a9187e2f6498326be5ab1cb50c83 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Wed, 1 Nov 2023 23:18:03 +0000 Subject: [PATCH 5/5] Fix doctests and newline in printing --- doc/source/general.rst | 1 + src/flint/flint_base/flint_context.pyx | 2 +- src/flint/test/test.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/general.rst b/doc/source/general.rst index 52156f0f..fb2ec9ac 100644 --- a/doc/source/general.rst +++ b/doc/source/general.rst @@ -46,6 +46,7 @@ The user can mutate the properties directly, for example:: >>> fmpq(3,2) fmpq(3,2) >>> ctx.pretty = True + >>> fmpq(3,2) 3/2 Calling ``ctx.default()`` restores the default settings. diff --git a/src/flint/flint_base/flint_context.pyx b/src/flint/flint_base/flint_context.pyx index c73c83bc..b344ddc8 100644 --- a/src/flint/flint_base/flint_context.pyx +++ b/src/flint/flint_base/flint_context.pyx @@ -63,7 +63,7 @@ cdef class FlintContext: "prec = %-8s # real/complex precision (in bits)\n" \ "dps = %-8s # real/complex precision (in digits)\n" \ "cap = %-8s # power series precision\n" \ - "threads = %-8s # max number of threads used internally\n" % \ + "threads = %-8s # max number of threads used internally" % \ (self.pretty, self.unicode, self.prec, self.dps, self.cap, self.threads) def cleanup(self): diff --git a/src/flint/test/test.py b/src/flint/test/test.py index 40c60a7e..aab785ee 100644 --- a/src/flint/test/test.py +++ b/src/flint/test/test.py @@ -30,7 +30,7 @@ def raises(f, exception): prec = 53 # real/complex precision (in bits) dps = 15 # real/complex precision (in digits) cap = 10 # power series precision -threads = 1 # max number of threads used internally +threads = 1 # max number of threads used internally\ """ def test_pyflint():