From 3d3380af7f021c35fd11b28f34cb5fec46eb70a8 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 18:57:44 +0100 Subject: [PATCH 1/8] Make FLINT 3.4 the minimum supported version (Drop 3.0-3.3) --- .github/workflows/buildwheel.yml | 18 +-- README.md | 17 +- bin/patch-flint-windows-arm64-link-3.3.1.diff | 27 ---- bin/pyodide_build_dependencies.sh | 2 +- doc/source/_gr.rst | 1 - doc/source/build.rst | 27 ++-- meson.build | 7 +- src/flint/flintlib/functions/acb_theta.pxd | 2 +- src/flint/flintlib/functions/compat.pxd | 31 ---- src/flint/flintlib/types/flint.pxd | 11 -- .../flintlib/types/fmpz_mod_mat_compat.pxd | 146 ------------------ src/flint/flintlib/types/gr.pxd | 27 ---- src/flint/test/test_docstrings.py | 12 -- src/flint/types/_gr.pxd | 12 +- src/flint/types/_gr.pyx | 4 - src/flint/types/acb_mat.pyx | 4 - src/flint/types/acb_theta.pyx | 67 +------- src/flint/types/fmpz_mod_mat.pyx | 102 ++++++------ src/flint/types/fmpz_mod_mpoly.pyx | 37 ++--- 19 files changed, 105 insertions(+), 449 deletions(-) delete mode 100644 bin/patch-flint-windows-arm64-link-3.3.1.diff delete mode 100644 src/flint/flintlib/types/fmpz_mod_mat_compat.pxd diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 7c07eb8a..e026db60 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -300,7 +300,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-24.04] + os: [ubuntu-26.04] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -332,7 +332,7 @@ jobs: # Test build with minimum Cython and meson-python versions. test_old_build_requires: name: 'Test old Cython/meson-python' - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -353,7 +353,7 @@ jobs: - run: pip install --no-build-isolation . - run: python -m flint.test --verbose - # For older Ubuntu we have to build Flint >= 3.0.0 + # Build and test against each supported FLINT release. test_flint_releases: name: Test flint ${{ matrix.flint-tag }} runs-on: ubuntu-22.04 @@ -362,11 +362,9 @@ jobs: matrix: # Supported Flint versions: flint-tag: [ - 'v3.0.1', - 'v3.2.2', - 'v3.3.1', 'v3.4.0', 'v3.5.0', + 'v3.6.0', ] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -416,7 +414,7 @@ jobs: # Test that we can make a coverage build and report coverage test_coverage_build_setuptools: name: Test coverage setuptools build - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -432,7 +430,7 @@ jobs: # Test that we can make a coverage build and report coverage test_coverage_build_meson: name: Test coverage meson build - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -448,7 +446,7 @@ jobs: # Run SymPy test suite against python-flint master test_sympy: name: Test SymPy ${{ matrix.sympy-version }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 strategy: fail-fast: false matrix: @@ -472,7 +470,7 @@ jobs: # Run SymPy master branch agains python-flint main test_sympy_master: name: Test SymPy master - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/README.md b/README.md index 8cbb492e..3cc45f72 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,10 @@ Build from source ----------------- For other platforms or architectures installation needs to build from source. -First install FLINT 3. Starting with python-flint 0.5.0 older versions of Flint -such as 2.9 are not supported any more. Note that as of Flint 3 Arb no longer -needs to be built separately as it is now merged into Flint. +First install FLINT 3.4 or newer. Note that as of Flint 3 Arb no longer needs +to be built separately as it is now merged into Flint. -As of e.g. Ubuntu 24.04 a new enough version of FLINT (at least version 3) can +As of e.g. Ubuntu 26.04 a new enough version of FLINT (at least version 3.4) can be installed from the Ubuntu repos like sudo apt-get install libflint-dev @@ -136,15 +135,14 @@ Compatibility table ------------------- Generally each release of python-flint will be compatible with a range of -Python versions. Since python-flint 0.5.0 the minimum supported Flint version -is `3.0` and each release of python-flint supports all versions of Flint -`>=3.0` available at the time of release. +Python and FLINT versions. The supported range for each release is shown +below. Compatible versions: | python-flint | Release date | CPython | FLINT | Cython | |--------------|---------------|-------------|------------|------------------| -| `0.10.0` | Not released | `3.10-3.15` | `3.0-3.6` | `3.1-3.3` | +| `0.10.0` | Not released | `3.10-3.15` | `3.4-3.6` | `3.1-3.3` | | `0.9.0` | 3rd Jul 2026 | `3.10-3.14` | `3.0-3.6` | `3.1-3.2` | | `0.8.0` | 29th Aug 2025 | `3.11-3.14` | `3.0-3.3` | `3.1` only | | `0.7.0` | 16th Mar 2025 | `3.11-3.13` | `3.0-3.2` | `3.0.11-3.1.0a1` | @@ -174,6 +172,9 @@ Contributors (0.10.0): Changes (0.10.0): +- Drop support for FLINT versions older than 3.4.0 and remove the associated + compatibility code. (OB) + - [gh-421](https://github.com/flintlib/python-flint/pull/421), Add `zpoly` and `zcontent` methods to `fmpq_mpoly`, to get the primitive integer polynomial and the `fmpq` content, which diff --git a/bin/patch-flint-windows-arm64-link-3.3.1.diff b/bin/patch-flint-windows-arm64-link-3.3.1.diff deleted file mode 100644 index 1b67c584..00000000 --- a/bin/patch-flint-windows-arm64-link-3.3.1.diff +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/Makefile.in b/Makefile.in -index 0f25aa2b5..f6f46b7d6 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -416,18 +416,12 @@ endif - ifneq ($(SHARED), 0) - shared: $(FLINT_DIR)/$(FLINT_LIB_FULL) - --# The following is to avoid reaching the maximum length of command line --# arguments, mainly present on MinGW. --define xxx_merged_lobj_rule --$(BUILD_DIR)/$(1)_merged.lo: $($(1)_LOBJS) | $(BUILD_DIR) -- @$(LD) -r $($(1)_LOBJS) -o $(BUILD_DIR)/$(1)_merged.lo --endef --$(foreach dir, $(DIRS), $(eval $(call xxx_merged_lobj_rule,$(dir)))) --MERGED_LOBJS:=$(foreach dir, $(DIRS),$(BUILD_DIR)/$(dir)_merged.lo) -+SHARED_LINK_RSP := $(BUILD_DIR)/libflint-shared.rsp - --$(FLINT_DIR)/$(FLINT_LIB_FULL): $(MERGED_LOBJS) -+$(FLINT_DIR)/$(FLINT_LIB_FULL): $(LOBJS) | $(BUILD_DIR) - @echo "Building $(FLINT_LIB_FULL)" -- @$(CC) $(CFLAGS) -shared $(EXTRA_SHARED_FLAGS) $(MERGED_LOBJS) -o $(FLINT_LIB_FULL) $(LDFLAGS) $(LIBS) -+ @: $(file >$(SHARED_LINK_RSP))$(foreach obj,$(LOBJS),$(file >>$(SHARED_LINK_RSP),$(obj))) -+ @$(CC) $(CFLAGS) -shared $(EXTRA_SHARED_FLAGS) @$(SHARED_LINK_RSP) -o $(FLINT_LIB_FULL) $(LDFLAGS) $(LIBS) - @$(RM_F) $(FLINT_LIB) - @$(RM_F) $(FLINT_LIB_MAJOR) - @$(LN_S) $(FLINT_LIB_FULL) $(FLINT_LIB) diff --git a/bin/pyodide_build_dependencies.sh b/bin/pyodide_build_dependencies.sh index bd43bde1..04157c1b 100755 --- a/bin/pyodide_build_dependencies.sh +++ b/bin/pyodide_build_dependencies.sh @@ -27,7 +27,7 @@ do shift ;; --flint-commit) - # e.g. --flint-commit 3.3.1 + # e.g. --flint-commit 3.4.0 FLINT_COMMIT="$2" shift shift diff --git a/doc/source/_gr.rst b/doc/source/_gr.rst index 11ad72a9..e69e467a 100644 --- a/doc/source/_gr.rst +++ b/doc/source/_gr.rst @@ -20,7 +20,6 @@ variables over the Gaussian integers :math:`\mathbb{Z}[i][x,y]` we would do:: >>> ctx.gens() [x, y] - # XXX: gens_recursive not available in FLINT < 3.1 # >>> ctx.gens_recursive() # [I, x, y] # >>> I, x, y = ctx.gens_recursive() diff --git a/doc/source/build.rst b/doc/source/build.rst index 11556216..f2b323a2 100644 --- a/doc/source/build.rst +++ b/doc/source/build.rst @@ -16,16 +16,16 @@ Simple build instructions The simple explanation of how to build ``python-flint`` from source is that there are two steps: -- Install ``FLINT >= 3.0`` (see :ref:`installing_the_dependencies` below). +- Install ``FLINT >= 3.4`` (see :ref:`installing_the_dependencies` below). - Run ``pip install --no-binary python-flint python-flint``. -For example on Ubuntu 24.04 (but not older versions of Ubuntu) and when installing -``python-flint >= 0.7.0`` these two steps are:: +For example on Ubuntu 26.04 (but not older versions of Ubuntu) these two steps +are:: sudo apt-get install libflint-dev pip install --no-binary python-flint python-flint -The first command installs ``FLINT 3.0.1`` system-wide. With the second command +The first command installs ``FLINT 3.4.0`` system-wide. With the second command ``pip`` will download the source code for the latest release of ``python-flint`` from PyPI, build it and install it into the active Python environment. When building, ``pip`` will create a temporary isolated build @@ -70,9 +70,8 @@ Compatibility and supported versions Generally each release of python-flint will be compatible with a range of Python versions as described in `SPEC 0 -`_. Since python-flint 0.5.0 -the minimum supported FLINT version is ``3.0`` and each release of python-flint -supports all versions of ``FLINT >= 3.0`` available at the time of release. +`_ and a range of FLINT +versions. The supported range for each release is shown below. Compatible versions: @@ -87,7 +86,7 @@ Compatible versions: * - 0.10.0 - Not released - 3.10-3.15 - - 3.0-3.6 + - 3.4-3.6 - 3.1-3.3 * - 0.9.0 - 3rd Jul 2026 @@ -289,15 +288,15 @@ The dependencies for building ``python-flint`` have changed over time. See :ref:`supported_versions` above for the versions of the dependencies that are supported by each version of ``python-flint``. -As of ``python-flint 0.7.0`` the runtime dependencies are Python and FLINT (at -least version 3.0) and the build-time dependencies are a C compiler, +The runtime dependencies are Python and FLINT (at least version 3.4) and the +build-time dependencies are a C compiler, ``Cython``, ``meson``, ``meson-python`` and ``ninja``. Commands shown above such as ``pip install .`` will install dependencies like ``Cython``, ``meson`` etc automatically. If you already have Python and a C compiler then what needs to be installed before building ``python-flint`` is ``FLINT``. -At the time of writing, few Linux distributions provide ``FLINT >= 3.0`` in -their package repositories but for example on ``Ubuntu 24.04`` (but not any +At the time of writing, few Linux distributions provide ``FLINT >= 3.4`` in +their package repositories but for example on ``Ubuntu 26.04`` (but not any earlier Ubuntu versions) you can install a sufficiently recent ``FLINT`` with:: sudo apt-get install libflint-dev @@ -307,7 +306,7 @@ On MacOS you can install FLINT from homebrew with:: brew install flint Other package managers may also provide ``FLINT`` but make sure that it is at -least version ``3.0``. +least version ``3.4``. Once ``FLINT`` is installed it should be possible to build ``python-flint`` with any of the commands shown above e.g.:: @@ -326,7 +325,7 @@ that uses ``apt-get`` to install all dependencies needed to build ``FLINT``, then builds ``FLINT`` from git using a specified git ref, and then installs ``FLINT`` system-wide:: - bin/install_flint_ubuntu.sh v3.0.1 # version 3.0.1 + bin/install_flint_ubuntu.sh v3.4.0 # version 3.4.0 bin/install_flint_ubuntu.sh main # latest git The script can be adapted for other Linux distributions or MacOS to use diff --git a/meson.build b/meson.build index ab150a67..91e53d90 100644 --- a/meson.build +++ b/meson.build @@ -15,7 +15,7 @@ project( # if it seems like new releases do not always break the build of python-flint # then we can consider not using a speculative upper version cap here. # -flint_lower = '>=3.0' +flint_lower = '>=3.4' flint_upper = '<3.7' cython_lower = '>=3.0.11' cython_upper = '<3.4' @@ -70,11 +70,6 @@ if get_option('flint_version_check') endif endif -# flint.pc was missing -lflint until Flint 3.1.0 -if flint_dep.version().version_compare('<3.1') - flint_dep = cc.find_library('flint') -endif - pyflint_deps = [gmp_dep, mpfr_dep, flint_dep] add_project_arguments( diff --git a/src/flint/flintlib/functions/acb_theta.pxd b/src/flint/flintlib/functions/acb_theta.pxd index fa4a6713..e2fa10ea 100644 --- a/src/flint/flintlib/functions/acb_theta.pxd +++ b/src/flint/flintlib/functions/acb_theta.pxd @@ -54,7 +54,7 @@ cdef extern from "flint/acb_theta.h": int acb_theta_char_is_even(ulong ab, slong g) void acb_theta_char_table(ulong * ch, slong * e, const fmpz_mat_t mat, ulong ab, int all) void acb_theta_char_shuffle(acb_ptr res, const fmpz_mat_t mat, acb_srcptr th, int sqr, slong prec) - slong acb_theta_jet_nb(slong ord, slong g) + slong acb_theta_jet_nb(slong g, slong ord) slong acb_theta_jet_total_order(const slong * tup, slong g) void acb_theta_jet_tuples(slong * tups, slong ord, slong g) slong acb_theta_jet_index(const slong * tup, slong g) diff --git a/src/flint/flintlib/functions/compat.pxd b/src/flint/flintlib/functions/compat.pxd index a1e3abda..c3aec99d 100644 --- a/src/flint/flintlib/functions/compat.pxd +++ b/src/flint/flintlib/functions/compat.pxd @@ -1,37 +1,9 @@ -from flint.flintlib.types.flint cimport slong -from flint.flintlib.types.fmpz_mod cimport fmpz_mod_mpoly_ctx_t, fmpz_mod_mpoly_t from flint.flintlib.types.gr cimport gr_ctx_t, gr_ptr, gr_srcptr, gr_vec_t cdef extern from *: """ #include "flint/gr.h" - #if __FLINT_RELEASE >= 30400 /* Flint 3.4.0 or later */ - #include "flint/gr_series.h" - #endif - - #if __FLINT_RELEASE >= 30400 /* Flint 3.4.0 or later */ - - #define compat_gr_ctx_init_gr_series(...) gr_series_ctx_init(__VA_ARGS__) - #define compat_gr_ctx_init_series_mod_gr_poly(...) gr_series_mod_ctx_init(__VA_ARGS__) - - #else - - #define compat_gr_ctx_init_gr_series(...) gr_ctx_init_gr_series(__VA_ARGS__) - #define compat_gr_ctx_init_series_mod_gr_poly(...) gr_ctx_init_series_mod_gr_poly(__VA_ARGS__) - - #endif - - #if __FLINT_RELEASE < 30200 /* Flint < 3.2.0 */ - - #define compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) (void)0 - - #else - - #define compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(__VA_ARGS__) - - #endif - #if __FLINT_RELEASE >= 30600 /* Flint 3.6.0 or later */ #define compat_gr_factor(c, factors, exponents, x, flags, ctx) gr_factor(c, factors, (fmpz_vec_struct *) exponents, x, flags, ctx) @@ -42,7 +14,4 @@ cdef extern from *: #endif """ - void compat_gr_ctx_init_gr_series(gr_ctx_t ctx, gr_ctx_t base_ring, slong prec) - void compat_gr_ctx_init_series_mod_gr_poly(gr_ctx_t ctx, gr_ctx_t base_ring, slong n) - void compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) int compat_gr_factor(gr_ptr c, gr_vec_t factors, gr_vec_t exponents, gr_srcptr x, int flags, gr_ctx_t ctx) diff --git a/src/flint/flintlib/types/flint.pxd b/src/flint/flintlib/types/flint.pxd index 319771e7..f61ea779 100644 --- a/src/flint/flintlib/types/flint.pxd +++ b/src/flint/flintlib/types/flint.pxd @@ -43,17 +43,6 @@ cdef extern from "flint/fmpz.h": # Macros int COEFF_IS_MPZ(fmpz_struct x) -cdef extern from *: - """ - #if __FLINT_RELEASE < 30200 /* Flint < 3.2.0 */ - - /* Functions renamed in Flint 3.2.0 */ - #define flint_rand_init flint_randinit - #define flint_rand_clear flint_randclear - - #endif - """ - cdef extern from "flint/flint.h": # These defines are needed to work around a Cython bug. # Otherwise sizeof(ulong) will give the wrong size on 64 bit Windows. diff --git a/src/flint/flintlib/types/fmpz_mod_mat_compat.pxd b/src/flint/flintlib/types/fmpz_mod_mat_compat.pxd deleted file mode 100644 index 916845b9..00000000 --- a/src/flint/flintlib/types/fmpz_mod_mat_compat.pxd +++ /dev/null @@ -1,146 +0,0 @@ -from flint.flintlib.types.flint cimport slong, fmpz_struct, fmpz_t -from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_t, fmpz_mod_mat_t, fmpz_mod_poly_t - -cdef extern from *: - """ - #include - #include - - /* - * fmpz_mod_mat function signatures were changed in FLINT 3.1.0 - */ - #if __FLINT_RELEASE >= 30100 /* Flint 3.1.0 or later */ - - #define compat_fmpz_mod_mat_init(mat, rows, cols, ctx) fmpz_mod_mat_init(mat, rows, cols, ctx) - #define compat_fmpz_mod_mat_init_set(mat, src, ctx) fmpz_mod_mat_init_set(mat, src, ctx) - #define compat_fmpz_mod_mat_clear(mat, ctx) fmpz_mod_mat_clear(mat, ctx) - #define compat_fmpz_mod_mat_set(A, B, ctx) fmpz_mod_mat_set(A, B, ctx) - #define compat_fmpz_mod_mat_nrows(mat, ctx) fmpz_mod_mat_nrows(mat, ctx) - #define compat_fmpz_mod_mat_ncols(mat, ctx) fmpz_mod_mat_ncols(mat, ctx) - #define compat_fmpz_mod_mat_entry(mat, i, j) fmpz_mod_mat_entry(mat, i, j) - #define compat_fmpz_mod_mat_set_entry(mat, i, j, val, ctx) fmpz_mod_mat_set_entry(mat, i, j, val, ctx) - #define compat_fmpz_mod_mat_one(mat, ctx) fmpz_mod_mat_one(mat, ctx) - #define compat_fmpz_mod_mat_equal(mat1, mat2, ctx) fmpz_mod_mat_equal(mat1, mat2, ctx) - #define compat_fmpz_mod_mat_is_zero(mat, ctx) fmpz_mod_mat_is_zero(mat, ctx) - #define compat_fmpz_mod_mat_neg(B, A, ctx) fmpz_mod_mat_neg(B, A, ctx) - #define compat_fmpz_mod_mat_add(C, A, B, ctx) fmpz_mod_mat_add(C, A, B, ctx) - #define compat_fmpz_mod_mat_sub(C, A, B, ctx) fmpz_mod_mat_sub(C, A, B, ctx) - #define compat_fmpz_mod_mat_scalar_mul_fmpz(B, A, c, ctx) fmpz_mod_mat_scalar_mul_fmpz(B, A, c, ctx) - #define compat_fmpz_mod_mat_mul(C, A, B, ctx) fmpz_mod_mat_mul(C, A, B, ctx) - #define compat_fmpz_mod_mat_inv(B, A, ctx) fmpz_mod_mat_inv(B, A, ctx) - #define compat_fmpz_mod_mat_transpose(B, A, ctx) fmpz_mod_mat_transpose(B, A, ctx) - #define compat_fmpz_mod_mat_solve(X, A, B, ctx) fmpz_mod_mat_solve(X, A, B, ctx) - #define compat_fmpz_mod_mat_rref(mat, ctx) fmpz_mod_mat_rref(mat, mat, ctx) - #define compat_fmpz_mod_mat_det(res, mat, ctx) fmpz_mod_mat_det(res, mat, ctx) - #define compat_fmpz_mod_mat_charpoly(p, M, ctx) fmpz_mod_mat_charpoly(p, M, ctx) - #define compat_fmpz_mod_mat_minpoly(p, M, ctx) fmpz_mod_mat_minpoly(p, M, ctx) - - #else /* Flint 3.0.0 or 3.0.1 */ - - #define compat_fmpz_mod_mat_init(mat, rows, cols, ctx) fmpz_mod_mat_init(mat, rows, cols, ctx->n) - #define compat_fmpz_mod_mat_init_set(mat, src, ctx) fmpz_mod_mat_init_set(mat, src) - #define compat_fmpz_mod_mat_clear(mat, ctx) fmpz_mod_mat_clear(mat) - #define compat_fmpz_mod_mat_set(A, B, ctx) fmpz_mod_mat_set(A, B) - #define compat_fmpz_mod_mat_nrows(mat, ctx) fmpz_mod_mat_nrows(mat) - #define compat_fmpz_mod_mat_ncols(mat, ctx) fmpz_mod_mat_ncols(mat) - #define compat_fmpz_mod_mat_entry(mat, i, j) fmpz_mod_mat_entry(mat, i, j) - #define compat_fmpz_mod_mat_set_entry(mat, i, j, val, ctx) fmpz_mod_mat_set_entry(mat, i, j, val) - #define compat_fmpz_mod_mat_one(mat, ctx) fmpz_mod_mat_one(mat) - #define compat_fmpz_mod_mat_equal(mat1, mat2, ctx) fmpz_mod_mat_equal(mat1, mat2) - #define compat_fmpz_mod_mat_is_zero(mat, ctx) fmpz_mod_mat_is_zero(mat) - #define compat_fmpz_mod_mat_neg(B, A, ctx) fmpz_mod_mat_neg(B, A) - #define compat_fmpz_mod_mat_add(C, A, B, ctx) fmpz_mod_mat_add(C, A, B) - #define compat_fmpz_mod_mat_sub(C, A, B, ctx) fmpz_mod_mat_sub(C, A, B) - #define compat_fmpz_mod_mat_scalar_mul_fmpz(B, A, c, ctx) fmpz_mod_mat_scalar_mul_fmpz(B, A, c) - #define compat_fmpz_mod_mat_mul(C, A, B, ctx) fmpz_mod_mat_mul(C, A, B) - #define compat_fmpz_mod_mat_inv(B, A, ctx) fmpz_mod_mat_inv(B, A) - #define compat_fmpz_mod_mat_transpose(B, A, ctx) fmpz_mod_mat_transpose(B, A) - #define compat_fmpz_mod_mat_solve(X, A, B, ctx) fmpz_mod_mat_solve(X, A, B) - #define compat_fmpz_mod_mat_rref(mat, ctx) fmpz_mod_mat_rref(NULL, mat) - #define compat_fmpz_mod_mat_det(res, mat, ctx) compat_fmpz_mod_mat_det_fallback(res, mat, ctx) - #define compat_fmpz_mod_mat_charpoly(p, M, ctx) fmpz_mod_mat_charpoly(p, M, ctx) - #define compat_fmpz_mod_mat_minpoly(p, M, ctx) fmpz_mod_mat_minpoly(p, M, ctx) - - /* fmpz_mod_mat_det was added in FLINT 3.1.0 */ - static inline void - compat_fmpz_mod_mat_det_fallback(fmpz_t res, const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - { - fmpz_mod_poly_t p; - - fmpz_mod_poly_init(p, ctx); - fmpz_mod_mat_charpoly(p, mat, ctx); - fmpz_mod_poly_get_coeff_fmpz(res, p, 0, ctx); - - if (fmpz_mod_mat_nrows(mat) % 2) - fmpz_mod_neg(res, res, ctx); - - fmpz_mod_poly_clear(p, ctx); - } - - #endif - """ - - -cdef extern from "flint/fmpz_mod_mat.h": - void compat_fmpz_mod_mat_init(fmpz_mod_mat_t mat, slong rows, slong cols, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_init_set(fmpz_mod_mat_t mat, const fmpz_mod_mat_t src, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_clear(fmpz_mod_mat_t mat, fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_set(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx) - slong compat_fmpz_mod_mat_nrows(const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - slong compat_fmpz_mod_mat_ncols(const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - fmpz_struct * compat_fmpz_mod_mat_entry(const fmpz_mod_mat_t mat, slong i, slong j) - void compat_fmpz_mod_mat_set_entry(fmpz_mod_mat_t mat, slong i, slong j, const fmpz_t val, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_one(fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - int compat_fmpz_mod_mat_equal(const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2, const fmpz_mod_ctx_t ctx) - int compat_fmpz_mod_mat_is_zero(const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_neg(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_add(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_sub(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_scalar_mul_fmpz(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, fmpz_t c, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_mul(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, const fmpz_mod_ctx_t ctx) - int compat_fmpz_mod_mat_inv(fmpz_mod_mat_t B, fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_transpose(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx) - int compat_fmpz_mod_mat_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, const fmpz_mod_ctx_t ctx) - slong compat_fmpz_mod_mat_rref(fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_det(fmpz_t res, const fmpz_mod_mat_t mat, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_charpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) - void compat_fmpz_mod_mat_minpoly(fmpz_mod_poly_t p, const fmpz_mod_mat_t M, const fmpz_mod_ctx_t ctx) - # - # The functions below are unused. The signatures shown are for Flint < 3.1.0 - # Probably compat_ versions are needed but each signature should be checked - # against Flint 3.1.0 or later. For now we comment these out. - # - # void _fmpz_mod_mat_set_mod(fmpz_mod_mat_t mat, const fmpz_t n) - # void fmpz_mod_mat_zero(fmpz_mod_mat_t mat) - # void fmpz_mod_mat_swap(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) - # void fmpz_mod_mat_swap_entrywise(fmpz_mod_mat_t mat1, fmpz_mod_mat_t mat2) - # int fmpz_mod_mat_is_empty(const fmpz_mod_mat_t mat) - # int fmpz_mod_mat_is_square(const fmpz_mod_mat_t mat) - # void _fmpz_mod_mat_reduce(fmpz_mod_mat_t mat) - # void fmpz_mod_mat_randtest(fmpz_mod_mat_t mat, flint_rand_t state) - # void fmpz_mod_mat_window_init(fmpz_mod_mat_t window, const fmpz_mod_mat_t mat, slong r1, slong c1, slong r2, slong c2) - # void fmpz_mod_mat_window_clear(fmpz_mod_mat_t window) - # void fmpz_mod_mat_concat_horizontal(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) - # void fmpz_mod_mat_concat_vertical(fmpz_mod_mat_t res, const fmpz_mod_mat_t mat1, const fmpz_mod_mat_t mat2) - # void fmpz_mod_mat_print_pretty(const fmpz_mod_mat_t mat) - # void fmpz_mod_mat_set_fmpz_mat(fmpz_mod_mat_t A, const fmpz_mat_t B) - # void fmpz_mod_mat_get_fmpz_mat(fmpz_mat_t A, const fmpz_mod_mat_t B) - # void fmpz_mod_mat_scalar_mul_si(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, slong c) - # void fmpz_mod_mat_scalar_mul_ui(fmpz_mod_mat_t B, const fmpz_mod_mat_t A, ulong c) - # # unimported types {'thread_pool_handle'} - # # void _fmpz_mod_mat_mul_classical_threaded_pool_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op, thread_pool_handle * threads, slong num_threads) - # void _fmpz_mod_mat_mul_classical_threaded_op(fmpz_mod_mat_t D, const fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B, int op) - # void fmpz_mod_mat_mul_classical_threaded(fmpz_mod_mat_t C, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) - # void fmpz_mod_mat_sqr(fmpz_mod_mat_t B, const fmpz_mod_mat_t A) - # void fmpz_mod_mat_mul_fmpz_vec(fmpz_struct * c, const fmpz_mod_mat_t A, const fmpz_struct * b, slong blen) - # void fmpz_mod_mat_mul_fmpz_vec_ptr(fmpz_struct * const * c, const fmpz_mod_mat_t A, const fmpz_struct * const * b, slong blen) - # void fmpz_mod_mat_fmpz_vec_mul(fmpz_struct * c, const fmpz_struct * a, slong alen, const fmpz_mod_mat_t B) - # void fmpz_mod_mat_fmpz_vec_mul_ptr(fmpz_struct * const * c, const fmpz_struct * const * a, slong alen, const fmpz_mod_mat_t B) - # void fmpz_mod_mat_trace(fmpz_t trace, const fmpz_mod_mat_t mat) - # void fmpz_mod_mat_strong_echelon_form(fmpz_mod_mat_t mat) - # slong fmpz_mod_mat_howell_form(fmpz_mod_mat_t mat) - # slong fmpz_mod_mat_lu(slong * P, fmpz_mod_mat_t A, int rank_check) - # void fmpz_mod_mat_solve_tril(fmpz_mod_mat_t X, const fmpz_mod_mat_t L, const fmpz_mod_mat_t B, int unit) - # void fmpz_mod_mat_solve_triu(fmpz_mod_mat_t X, const fmpz_mod_mat_t U, const fmpz_mod_mat_t B, int unit) - # int fmpz_mod_mat_can_solve(fmpz_mod_mat_t X, const fmpz_mod_mat_t A, const fmpz_mod_mat_t B) - # void fmpz_mod_mat_similarity(fmpz_mod_mat_t M, slong r, fmpz_t d) diff --git a/src/flint/flintlib/types/gr.pxd b/src/flint/flintlib/types/gr.pxd index 62a00bab..f3b886e3 100644 --- a/src/flint/flintlib/types/gr.pxd +++ b/src/flint/flintlib/types/gr.pxd @@ -5,33 +5,6 @@ from flint.flintlib.types.flint cimport ( flint_bitcnt_t, ) -cdef extern from *: - """ - /* - * The following functions were introduced in FLINT 3.1.0 - */ - #if __FLINT_RELEASE < 30100 - #define gr_div_nonunique(res, x, y, ctx) GR_UNABLE - #endif - - /* - * The following functions were introduced in FLINT 3.2.0 - */ - #if __FLINT_RELEASE < 30200 - #define gr_min(res, x, y, ctx) GR_UNABLE - #define gr_max(res, x, y, ctx) GR_UNABLE - #define gr_le(x, y, ctx) T_UNKNOWN - #define gr_lt(x, y, ctx) T_UNKNOWN - #define gr_ge(x, y, ctx) T_UNKNOWN - #define gr_gt(x, y, ctx) T_UNKNOWN - #define gr_abs_le(x, y, ctx) T_UNKNOWN - #define gr_abs_lt(x, y, ctx) T_UNKNOWN - #define gr_abs_ge(x, y, ctx) T_UNKNOWN - #define gr_abs_gt(x, y, ctx) T_UNKNOWN - #endif - """ - - # XXX: This is needed with FLINT 3.5.0 because we need to ensure that # fmpq_poly.h is included before gr.h or gr_ctx_init_nf and # gr_ctx_init_nf_fmpz_poly will not be included. The order of header includes diff --git a/src/flint/test/test_docstrings.py b/src/flint/test/test_docstrings.py index 8c2b8c56..2ca1b809 100644 --- a/src/flint/test/test_docstrings.py +++ b/src/flint/test/test_docstrings.py @@ -7,13 +7,6 @@ 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": 30100, -} - - def find_doctests(module): finder = doctest.DocTestFinder() tests = [] @@ -39,11 +32,6 @@ def find_doctests(module): 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) diff --git a/src/flint/types/_gr.pxd b/src/flint/types/_gr.pxd index 8ead1bee..35409826 100644 --- a/src/flint/types/_gr.pxd +++ b/src/flint/types/_gr.pxd @@ -34,11 +34,8 @@ from flint.flintlib.functions.fmpq_poly cimport ( ) from flint.flintlib.functions.compat cimport ( compat_gr_factor, - compat_gr_ctx_init_gr_series, - # compat_gr_ctx_init_series_mod_gr_poly, ) - from flint.flintlib.types.gr cimport ( truth_t, T_TRUE, @@ -53,6 +50,11 @@ from flint.flintlib.types.gr cimport ( gr_ptr, gr_vec_t, ) + +cdef extern from "flint/gr_series.h": + void gr_series_ctx_init(gr_ctx_t ctx, gr_ctx_t base_ring, slong prec) + # void gr_series_mod_ctx_init(gr_ctx_t ctx, gr_ctx_t base_ring, slong n) + from flint.flintlib.functions.gr_domains cimport ( gr_ctx_init_fmpz, gr_ctx_init_fmpq, @@ -1518,7 +1520,7 @@ cdef class gr_gr_mpoly_ctx(gr_mpoly_ctx): # cdef inline gr_series_mod_gr_poly_ctx _new(gr_ctx base_ctx, slong n): # cdef gr_series_mod_gr_poly_ctx ctx # ctx = gr_series_mod_gr_poly_ctx.__new__(gr_series_mod_gr_poly_ctx) -# compat_gr_ctx_init_series_mod_gr_poly(ctx.ctx_t, base_ctx.ctx_t, n) +# gr_series_mod_ctx_init(ctx.ctx_t, base_ctx.ctx_t, n) # ctx._init = True # ctx.base_ctx = base_ctx # ctx._n = n @@ -1534,7 +1536,7 @@ cdef class gr_series_ctx(gr_ctx): cdef inline gr_series_ctx _new(gr_ctx base_ctx, slong prec): cdef gr_series_ctx ctx ctx = gr_series_ctx.__new__(gr_series_ctx) - compat_gr_ctx_init_gr_series(ctx.ctx_t, base_ctx.ctx_t, prec) + gr_series_ctx_init(ctx.ctx_t, base_ctx.ctx_t, prec) ctx._init = True ctx.base_ctx = base_ctx ctx._prec = prec diff --git a/src/flint/types/_gr.pyx b/src/flint/types/_gr.pyx index 3c1128d3..4bb2cda1 100644 --- a/src/flint/types/_gr.pyx +++ b/src/flint/types/_gr.pyx @@ -344,8 +344,6 @@ cdef class gr_ctx(flint_ctx): def gens(self) -> list[gr]: """Return the top-level generators of the domain - # XXX: Does not work with FLINT < 3.1 - # >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx # >>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ['x', 'y']) # >>> ctx.gens() @@ -1098,7 +1096,6 @@ cdef class gr_fq_nmod_ctx(gr_scalar_ctx): def new(p, d, name=None) -> gr_fq_nmod_ctx: """Create a new context for finite fields. - # XXX: Does not work with FLINT < 3.1 # >>> from flint.types._gr import gr_fq_nmod_ctx # >>> F9 = gr_fq_nmod_ctx.new(3, 2) # >>> F9 @@ -1151,7 +1148,6 @@ cdef class gr_fq_zech_ctx(gr_scalar_ctx): def new(p, d, name=None) -> gr_fq_zech_ctx: """Create a new context for finite fields with small characteristic. - # XXX: Does not work with FLINT < 3.1 # >>> from flint.types._gr import gr_fq_zech_ctx # >>> F9 = gr_fq_zech_ctx.new(3, 2) # >>> F9 diff --git a/src/flint/types/acb_mat.pyx b/src/flint/types/acb_mat.pyx index 809fc02a..ecd928fb 100644 --- a/src/flint/types/acb_mat.pyx +++ b/src/flint/types/acb_mat.pyx @@ -835,8 +835,6 @@ cdef class acb_mat(flint_mat): for the ordering of the theta characteristics. """ - if acb_theta is None: - raise NotImplementedError("acb_mat.theta needs Flint >= 3.1.0") return acb_theta(z, tau, square=square) def theta_jets(tau, z, ord): @@ -854,6 +852,4 @@ cdef class acb_mat(flint_mat): one column for each jet coefficient. """ - if acb_theta_jets is None: - raise NotImplementedError("acb_mat.theta_jets needs Flint >= 3.3.0") return acb_theta_jets(z, tau, ord) diff --git a/src/flint/types/acb_theta.pyx b/src/flint/types/acb_theta.pyx index 240faaf6..3243393f 100644 --- a/src/flint/types/acb_theta.pyx +++ b/src/flint/types/acb_theta.pyx @@ -1,5 +1,4 @@ from flint.flint_base.flint_context cimport getprec -from flint.flint_base.flint_base import FLINT_RELEASE from flint.types.acb cimport acb from flint.types.acb_mat cimport acb_mat from flint.flintlib.functions.acb cimport * @@ -10,61 +9,10 @@ from flint.flintlib.types.acb cimport ( acb_srcptr, ) from flint.flintlib.functions.acb_mat cimport * +from flint.flintlib.functions.acb_theta cimport * from flint.flintlib.types.flint cimport slong, ulong -cdef extern from *: - """ - #include "flint/flint.h" - #include "flint/acb.h" - #include "flint/acb_mat.h" - - #if __FLINT_RELEASE >= 30100 /* Flint 3.1.0 or later */ - #include "flint/acb_theta.h" - static inline void - compat_acb_theta_all(acb_ptr th, acb_srcptr z, const acb_mat_t tau, int sqr, slong prec) - { - acb_theta_all(th, z, tau, sqr, prec); - } - #else - static inline void - compat_acb_theta_all(acb_ptr th, acb_srcptr z, const acb_mat_t tau, int sqr, slong prec) - { - } - #endif - - #if __FLINT_RELEASE >= 30300 /* Flint 3.3.0 or later */ - static inline slong - compat_acb_theta_jet_nb(slong ord, slong g) - { - return acb_theta_jet_nb(g, ord); - } - - static inline void - compat_acb_theta_jet(acb_ptr th, acb_srcptr zs, slong nb, const acb_mat_t tau, - slong ord, ulong ab, int all, int sqr, slong prec) - { - acb_theta_jet(th, zs, nb, tau, ord, ab, all, sqr, prec); - } - #else - static inline slong - compat_acb_theta_jet_nb(slong ord, slong g) - { - return 0; - } - - static inline void - compat_acb_theta_jet(acb_ptr th, acb_srcptr zs, slong nb, const acb_mat_t tau, - slong ord, ulong ab, int all, int sqr, slong prec) - { - } - #endif - """ - void compat_acb_theta_all(acb_ptr th, acb_srcptr z, const acb_mat_t tau, int sqr, slong prec) - slong compat_acb_theta_jet_nb(slong ord, slong g) - void compat_acb_theta_jet(acb_ptr th, acb_srcptr zs, slong nb, const acb_mat_t tau, slong ord, ulong ab, int all, int sqr, slong prec) - - def acb_theta(acb_mat z, acb_mat tau, ulong square=False): r""" Computes the vector valued Riemann theta function @@ -140,7 +88,7 @@ def acb_theta(acb_mat z, acb_mat tau, ulong square=False): cdef slong nb = 1 << (2 * g) cdef acb_ptr theta = _acb_vec_init(nb) - compat_acb_theta_all(theta, zvec, tau.val, square, getprec()) + acb_theta_all(theta, zvec, tau.val, square, getprec()) _acb_vec_clear(zvec, g) # copy the output res = [] @@ -188,7 +136,7 @@ def acb_theta_jets(acb_mat z, acb_mat tau, slong ord): # Calculate the length of the jet for one characteristic # This is the number of multi-indices (alpha) such that |alpha| < ord - cdef slong nj = compat_acb_theta_jet_nb(ord, g) + cdef slong nj = acb_theta_jet_nb(g, ord) # Total number of characteristics cdef slong nb = 1 << (2 * g) @@ -213,7 +161,7 @@ def acb_theta_jets(acb_mat z, acb_mat tau, slong ord): # Call the FLINT C function # Note: Computes all partial derivatives up to total order 'ord' - compat_acb_theta_jet(theta, zvec, nb_in, tau.val, ord, ab, all, square, getprec()) + acb_theta_jet(theta, zvec, nb_in, tau.val, ord, ab, all, square, getprec()) # Copy the output into a structured format res_mat = acb_mat(nb, nj) @@ -226,10 +174,3 @@ def acb_theta_jets(acb_mat z, acb_mat tau, slong ord): _acb_vec_clear(theta, total_size) return res_mat - - -if FLINT_RELEASE < 30100: - acb_theta = None - -if FLINT_RELEASE < 30300: - acb_theta_jets = None diff --git a/src/flint/types/fmpz_mod_mat.pyx b/src/flint/types/fmpz_mod_mat.pyx index 3e4f824c..f1e09d72 100644 --- a/src/flint/types/fmpz_mod_mat.pyx +++ b/src/flint/types/fmpz_mod_mat.pyx @@ -7,30 +7,30 @@ from flint.flintlib.functions.fmpz cimport ( fmpz_init_set, fmpz_set, ) -from flint.flintlib.types.fmpz_mod_mat_compat cimport ( - compat_fmpz_mod_mat_init, - compat_fmpz_mod_mat_init_set, - compat_fmpz_mod_mat_clear, - compat_fmpz_mod_mat_set, - compat_fmpz_mod_mat_nrows, - compat_fmpz_mod_mat_ncols, - compat_fmpz_mod_mat_entry, - compat_fmpz_mod_mat_set_entry, - compat_fmpz_mod_mat_one, - compat_fmpz_mod_mat_equal, - compat_fmpz_mod_mat_is_zero, - compat_fmpz_mod_mat_neg, - compat_fmpz_mod_mat_add, - compat_fmpz_mod_mat_sub, - compat_fmpz_mod_mat_mul, - compat_fmpz_mod_mat_scalar_mul_fmpz, - compat_fmpz_mod_mat_inv, - compat_fmpz_mod_mat_transpose, - compat_fmpz_mod_mat_solve, - compat_fmpz_mod_mat_rref, - compat_fmpz_mod_mat_det, - compat_fmpz_mod_mat_charpoly, - compat_fmpz_mod_mat_minpoly, +from flint.flintlib.functions.fmpz_mod_mat cimport ( + fmpz_mod_mat_init, + fmpz_mod_mat_init_set, + fmpz_mod_mat_clear, + fmpz_mod_mat_set, + fmpz_mod_mat_nrows, + fmpz_mod_mat_ncols, + fmpz_mod_mat_entry, + fmpz_mod_mat_set_entry, + fmpz_mod_mat_one, + fmpz_mod_mat_equal, + fmpz_mod_mat_is_zero, + fmpz_mod_mat_neg, + fmpz_mod_mat_add, + fmpz_mod_mat_sub, + fmpz_mod_mat_mul, + fmpz_mod_mat_scalar_mul_fmpz, + fmpz_mod_mat_inv, + fmpz_mod_mat_transpose, + fmpz_mod_mat_solve, + fmpz_mod_mat_rref, + fmpz_mod_mat_det, + fmpz_mod_mat_charpoly, + fmpz_mod_mat_minpoly, ) from flint.flint_base.flint_base cimport ( @@ -81,7 +81,7 @@ cdef class fmpz_mod_mat(flint_mat): """ def __dealloc__(self): if self._initialized: - compat_fmpz_mod_mat_clear(self.val, self.ctx.val) + fmpz_mod_mat_clear(self.val, self.ctx.val) def __init__(self, *args): """Construct an ``fmpz_mod_mat`` matrix. @@ -150,7 +150,7 @@ cdef class fmpz_mod_mat(flint_mat): cdef void _init_empty_ctx(self, slong m, slong n, fmpz_mod_ctx ctx): """Initialize an empty matrix with a given modulus context.""" self.ctx = ctx - compat_fmpz_mod_mat_init(self.val, m, n, ctx.val) + fmpz_mod_mat_init(self.val, m, n, ctx.val) self._initialized = True cdef void _init_empty(self, slong m, slong n, list args): @@ -173,7 +173,7 @@ cdef class fmpz_mod_mat(flint_mat): if val is NotImplemented: raise TypeError("fmpz_mod_mat: incompatible entries") e = val - compat_fmpz_mod_mat_set_entry(self.val, i, j, e.val, ctx.val) + fmpz_mod_mat_set_entry(self.val, i, j, e.val, ctx.val) # XXX: Should be possible to type this as flint_mat but nmod_mat is not a subclass # cdef void _init_from_matrix(self, flint_mat M, list args): @@ -190,7 +190,7 @@ cdef class fmpz_mod_mat(flint_mat): ctx = N1.ctx if N1.ctx != ctx: raise TypeError("fmpz_mod_mat: incompatible moduli") - compat_fmpz_mod_mat_init_set(self.val, N1.val, ctx.val) + fmpz_mod_mat_init_set(self.val, N1.val, ctx.val) self.ctx = ctx self._initialized = True elif typecheck(M, fmpz_mat): @@ -214,7 +214,7 @@ cdef class fmpz_mod_mat(flint_mat): """Create an initialized matrix of given shape and context.""" cdef fmpz_mod_mat res res = fmpz_mod_mat.__new__(fmpz_mod_mat) - compat_fmpz_mod_mat_init(res.val, m, n, ctx.val) + fmpz_mod_mat_init(res.val, m, n, ctx.val) res.ctx = ctx res._initialized = True return res @@ -227,16 +227,16 @@ cdef class fmpz_mod_mat(flint_mat): """Create a copy of the matrix.""" cdef fmpz_mod_mat res res = self._newlike() - compat_fmpz_mod_mat_set(res.val, self.val, self.ctx.val) + fmpz_mod_mat_set(res.val, self.val, self.ctx.val) return res cpdef slong nrows(self): """Return the number of rows.""" - return compat_fmpz_mod_mat_nrows(self.val, self.ctx.val) + return fmpz_mod_mat_nrows(self.val, self.ctx.val) cpdef slong ncols(self): """Return the number of columns.""" - return compat_fmpz_mod_mat_ncols(self.val, self.ctx.val) + return fmpz_mod_mat_ncols(self.val, self.ctx.val) def modulus(self): """Return the modulus.""" @@ -249,7 +249,7 @@ cdef class fmpz_mod_mat(flint_mat): """Retrieve an element as an ``fmpz_mod``.""" cdef fmpz_struct * p_e cdef fmpz_mod e - p_e = compat_fmpz_mod_mat_entry(self.val, i, j) + p_e = fmpz_mod_mat_entry(self.val, i, j) e = fmpz_mod.__new__(fmpz_mod) fmpz_set(e.val, p_e) e.ctx = self.ctx @@ -257,7 +257,7 @@ cdef class fmpz_mod_mat(flint_mat): cdef void _setitem(self, slong i, slong j, fmpz_t e): """Set an element from a raw ``fmpz_t``.""" - compat_fmpz_mod_mat_set_entry(self.val, i, j, e, self.ctx.val) + fmpz_mod_mat_set_entry(self.val, i, j, e, self.ctx.val) def repr(self): """Return a representation string.""" @@ -304,7 +304,7 @@ cdef class fmpz_mod_mat(flint_mat): def __bool__(self): """Return ``True`` if the matrix has any nonzero entries.""" cdef bint zero - zero = compat_fmpz_mod_mat_is_zero(self.val, self.ctx.val) + zero = fmpz_mod_mat_is_zero(self.val, self.ctx.val) return not zero def __richcmp__(self, other, int op): @@ -321,7 +321,7 @@ cdef class fmpz_mod_mat(flint_mat): if (self).ctx != (other).ctx: res = 0 else: - res = compat_fmpz_mod_mat_equal((self).val, (other).val, self.ctx.val) + res = fmpz_mod_mat_equal((self).val, (other).val, self.ctx.val) if op == 2: return res @@ -335,7 +335,7 @@ cdef class fmpz_mod_mat(flint_mat): def __neg__(self): """``-M``""" res = self._newlike() - compat_fmpz_mod_mat_neg(( res).val, self.val, self.ctx.val) + fmpz_mod_mat_neg(( res).val, self.val, self.ctx.val) return res def _as_fmpz_mod_mat(self, other, same_shape=True): @@ -354,13 +354,13 @@ cdef class fmpz_mod_mat(flint_mat): def _add(self, fmpz_mod_mat other): """Add two ``fmpz_mod_mat`` matrices.""" res = self._newlike() - compat_fmpz_mod_mat_add(res.val, self.val, other.val, self.ctx.val) + fmpz_mod_mat_add(res.val, self.val, other.val, self.ctx.val) return res def _sub(self, fmpz_mod_mat other): """Subtract two ``fmpz_mod_mat`` matrices.""" res = self._newlike() - compat_fmpz_mod_mat_sub(res.val, self.val, other.val, self.ctx.val) + fmpz_mod_mat_sub(res.val, self.val, other.val, self.ctx.val) return res def _matmul(self, fmpz_mod_mat other): @@ -368,13 +368,13 @@ cdef class fmpz_mod_mat(flint_mat): if self.ncols() != other.nrows(): raise ValueError("Shape mismatch: cannot multiply matrices") res = self._new(self.nrows(), other.ncols(), self.ctx) - compat_fmpz_mod_mat_mul(res.val, self.val, other.val, self.ctx.val) + fmpz_mod_mat_mul(res.val, self.val, other.val, self.ctx.val) return res def _scalarmul(self, fmpz_mod other): """Multiply an ``fmpz_mod_mat`` matrix by an ``fmpz_mod`` scalar.""" res = self._newlike() - compat_fmpz_mod_mat_scalar_mul_fmpz(res.val, self.val, other.val, self.ctx.val) + fmpz_mod_mat_scalar_mul_fmpz(res.val, self.val, other.val, self.ctx.val) return res def _pow(self, slong other): @@ -388,14 +388,14 @@ cdef class fmpz_mod_mat(flint_mat): other = -other res = self._newlike() - compat_fmpz_mod_mat_one(res.val, self.ctx.val) + fmpz_mod_mat_one(res.val, self.ctx.val) tmp = self._copy() while other > 0: if other % 2 == 1: - compat_fmpz_mod_mat_mul(res.val, res.val, tmp.val, self.ctx.val) - compat_fmpz_mod_mat_mul(tmp.val, tmp.val, tmp.val, self.ctx.val) + fmpz_mod_mat_mul(res.val, res.val, tmp.val, self.ctx.val) + fmpz_mod_mat_mul(tmp.val, tmp.val, tmp.val, self.ctx.val) other //= 2 return res @@ -487,7 +487,7 @@ cdef class fmpz_mod_mat(flint_mat): if self.nrows() != self.ncols(): raise ValueError("fmpz_mod_mat inv: matrix must be square") res = self._newlike() - r = compat_fmpz_mod_mat_inv(res.val, self.val, self.ctx.val) + r = fmpz_mod_mat_inv(res.val, self.val, self.ctx.val) if r == 0: raise ZeroDivisionError("fmpz_mod_mat inv: matrix is not invertible") return res @@ -507,7 +507,7 @@ cdef class fmpz_mod_mat(flint_mat): raise ValueError("fmpz_mod_mat det: matrix must be square") d = fmpz_mod.__new__(fmpz_mod) d.ctx = self.ctx - compat_fmpz_mod_mat_det(d.val, self.val, self.ctx.val) + fmpz_mod_mat_det(d.val, self.val, self.ctx.val) return d def charpoly(self): @@ -528,7 +528,7 @@ cdef class fmpz_mod_mat(flint_mat): pctx = fmpz_mod_poly_ctx(self.ctx) res = fmpz_mod_poly(0, pctx) - compat_fmpz_mod_mat_charpoly(res.val, self.val, self.ctx.val) + fmpz_mod_mat_charpoly(res.val, self.val, self.ctx.val) return res def minpoly(self): @@ -551,7 +551,7 @@ cdef class fmpz_mod_mat(flint_mat): pctx = fmpz_mod_poly_ctx(self.ctx) res = fmpz_mod_poly(0, pctx) - compat_fmpz_mod_mat_minpoly(res.val, self.val, self.ctx.val) + fmpz_mod_mat_minpoly(res.val, self.val, self.ctx.val) return res def transpose(self): @@ -569,7 +569,7 @@ cdef class fmpz_mod_mat(flint_mat): """ cdef fmpz_mod_mat res res = self._new(self.ncols(), self.nrows(), self.ctx) - compat_fmpz_mod_mat_transpose(res.val, self.val, self.ctx.val) + fmpz_mod_mat_transpose(res.val, self.val, self.ctx.val) return res def solve(self, rhs): @@ -600,7 +600,7 @@ cdef class fmpz_mod_mat(flint_mat): raise ValueError("fmpz_mod_mat solve: shape mismatch") res = self._new(rhs.nrows(), rhs.ncols(), self.ctx) - success = compat_fmpz_mod_mat_solve(res.val, self.val, ( rhs).val, self.ctx.val) + success = fmpz_mod_mat_solve(res.val, self.val, ( rhs).val, self.ctx.val) if not success: raise ZeroDivisionError("Singular matrix in solve") @@ -643,5 +643,5 @@ cdef class fmpz_mod_mat(flint_mat): res = self else: res = self._copy() - r = compat_fmpz_mod_mat_rref(res.val, res.ctx.val) + r = fmpz_mod_mat_rref(res.val, res.val, res.ctx.val) return (res, r) diff --git a/src/flint/types/fmpz_mod_mpoly.pyx b/src/flint/types/fmpz_mod_mpoly.pyx index a66dd219..354ed380 100644 --- a/src/flint/types/fmpz_mod_mpoly.pyx +++ b/src/flint/types/fmpz_mod_mpoly.pyx @@ -9,8 +9,6 @@ from flint.flint_base.flint_base cimport ( ordering_c_to_py, ) -from flint.flint_base.flint_base import FLINT_RELEASE - from flint.utils.typecheck cimport typecheck from flint.utils.flint_exceptions import DomainError, IncompatibleContextError @@ -25,6 +23,7 @@ from flint.flintlib.functions.fmpz_mod_mpoly cimport ( fmpz_mod_mpoly_add_fmpz, fmpz_mod_mpoly_clear, fmpz_mod_mpoly_compose_fmpz_mod_mpoly, + fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen, fmpz_mod_mpoly_ctx_get_modulus, fmpz_mod_mpoly_ctx_init, fmpz_mod_mpoly_deflate, @@ -74,11 +73,6 @@ from flint.flintlib.functions.fmpz_mod_mpoly_factor cimport ( fmpz_mod_mpoly_factor_squarefree, fmpz_mod_mpoly_factor_t, ) -from flint.flintlib.functions.compat cimport compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen - -from flint.types.fmpz_mpoly cimport fmpz_mpoly_ctx, fmpz_mpoly - - from cpython.object cimport Py_EQ, Py_NE cimport libc.stdlib @@ -1116,27 +1110,16 @@ cdef class fmpz_mod_mpoly(flint_mpoly): return stride.to_list_int(), shift.to_list_int() cdef _compose_gens_(self, ctx, slong *mapping): - # FIXME: Remove this when FLINT < 3.2 is dropped cdef fmpz_mod_mpoly res - if FLINT_RELEASE >= 30200: - res = create_fmpz_mod_mpoly(ctx) - compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen( - res.val, - self.val, - mapping, - self.ctx.val, - (ctx).val - ) - return res - - cdef: - fmpz_mpoly_ctx mpoly_ctx = fmpz_mpoly_ctx.from_context(self.context()) - fmpz_mpoly_ctx res_ctx = fmpz_mpoly_ctx.from_context(ctx) - - fmpz_mpoly poly = mpoly_ctx.from_dict(self.to_dict()) - fmpz_mpoly res1 = poly._compose_gens_(res_ctx, mapping) - - return ctx.from_dict(res1.to_dict()) + res = create_fmpz_mod_mpoly(ctx) + fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen( + res.val, + self.val, + mapping, + self.ctx.val, + (ctx).val + ) + return res @cython.final From 5b13ee91f9c8b42b4a7a89dbb121b1cd048c0dcb Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 19:27:30 +0100 Subject: [PATCH 2/8] Renable some previously disabled tests (due to old FLINT versions) --- README.md | 4 +- doc/source/_gr.rst | 6 +-- src/flint/test/test_docstrings.py | 13 +++++ src/flint/types/_gr.pxd | 40 +++++++-------- src/flint/types/_gr.pyx | 84 +++++++++++++++++-------------- src/flint/types/acb_theta.pyx | 2 - 6 files changed, 84 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 3cc45f72..15939642 100644 --- a/README.md +++ b/README.md @@ -172,9 +172,9 @@ Contributors (0.10.0): Changes (0.10.0): -- Drop support for FLINT versions older than 3.4.0 and remove the associated +- [gh-424](https://github.com/flintlib/python-flint/pull/424), + Drop support for FLINT versions older than 3.4.0 and remove the associated compatibility code. (OB) - - [gh-421](https://github.com/flintlib/python-flint/pull/421), Add `zpoly` and `zcontent` methods to `fmpq_mpoly`, to get the primitive integer polynomial and the `fmpq` content, which diff --git a/doc/source/_gr.rst b/doc/source/_gr.rst index e69e467a..5f2d9b2d 100644 --- a/doc/source/_gr.rst +++ b/doc/source/_gr.rst @@ -20,9 +20,9 @@ variables over the Gaussian integers :math:`\mathbb{Z}[i][x,y]` we would do:: >>> ctx.gens() [x, y] - # >>> ctx.gens_recursive() - # [I, x, y] - # >>> I, x, y = ctx.gens_recursive() + >>> ctx.gens_recursive() + [I, x, y] + >>> I, x, y = ctx.gens_recursive() >>> x, y = ctx.gens() >>> p = (x + y)**2 diff --git a/src/flint/test/test_docstrings.py b/src/flint/test/test_docstrings.py index 2ca1b809..b78cb741 100644 --- a/src/flint/test/test_docstrings.py +++ b/src/flint/test/test_docstrings.py @@ -7,6 +7,15 @@ dunder_test_regex = re.compile(r'^(.*?)__test__\.(.*?) \(line (\d+)\)$') +# Minimum FLINT release required by doctests that use newer FLINT features. +# Keys are doctest names and values are encoded __FLINT_RELEASE values, e.g.: +# +# test_flint_at_least = { +# "flint.types.example.example_method": 30700, +# } +test_flint_at_least = {} + + def find_doctests(module): finder = doctest.DocTestFinder() tests = [] @@ -32,6 +41,10 @@ def find_doctests(module): raise Exception(f"Duplicate test name: {test.name}") tests_seen.remove(test.name) + 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) diff --git a/src/flint/types/_gr.pxd b/src/flint/types/_gr.pxd index 35409826..d2ccd7e6 100644 --- a/src/flint/types/_gr.pxd +++ b/src/flint/types/_gr.pxd @@ -105,7 +105,7 @@ from flint.flintlib.functions.gr cimport ( gr_one, gr_gen, gr_gens, - # gr_gens_recursive, + gr_gens_recursive, gr_ctx_set_gen_names, gr_i, @@ -1017,25 +1017,25 @@ cdef class gr_ctx(flint_ctx): raise self._error(err, "Cannot compute min(x) in this context") return res - # @cython.final - # cdef inline list _gens_recursive(self): - # cdef int err - # cdef gr g - # cdef gr_vec_t gens - # gr_vec_init(gens, 0, self.ctx_t) - # err = gr_gens_recursive(gens, self.ctx_t) - # if err != GR_SUCCESS: - # raise self._error(err, "Cannot get recursive generators") - # length = gr_vec_length(gens, self.ctx_t) - # py_gens = [None] * length - # for 0 <= i < length: - # g = self.new_gr() - # err = gr_set(g.pval, gr_vec_entry_ptr(gens, i, self.ctx_t), self.ctx_t) - # if err != GR_SUCCESS: - # raise self._error(err, "Failed to copy generator.") - # py_gens[i] = g - # gr_vec_clear(gens, self.ctx_t) - # return py_gens + @cython.final + cdef inline list _gens_recursive(self): + cdef int err + cdef gr g + cdef gr_vec_t gens + gr_vec_init(gens, 0, self.ctx_t) + err = gr_gens_recursive(gens, self.ctx_t) + if err != GR_SUCCESS: + raise self._error(err, "Cannot get recursive generators") + length = gr_vec_length(gens, self.ctx_t) + py_gens = [None] * length + for 0 <= i < length: + g = self.new_gr() + err = gr_set(g.pval, gr_vec_entry_ptr(gens, i, self.ctx_t), self.ctx_t) + if err != GR_SUCCESS: + raise self._error(err, "Failed to copy generator.") + py_gens[i] = g + gr_vec_clear(gens, self.ctx_t) + return py_gens cdef class gr_scalar_ctx(gr_ctx): diff --git a/src/flint/types/_gr.pyx b/src/flint/types/_gr.pyx index 4bb2cda1..cf4b7b7b 100644 --- a/src/flint/types/_gr.pyx +++ b/src/flint/types/_gr.pyx @@ -344,17 +344,25 @@ cdef class gr_ctx(flint_ctx): def gens(self) -> list[gr]: """Return the top-level generators of the domain - # >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx - # >>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ['x', 'y']) - # >>> ctx.gens() - # [x, y] - # >>> gr_fmpzi_ctx.gens() - # [I] - # >>> ctx.gens_recursive() - # [I, x, y] + >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx + >>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ['x', 'y']) + >>> ctx.gens() + [x, y] + >>> gr_fmpzi_ctx.gens() + [I] """ return self._gens() + def gens_recursive(self) -> list[gr]: + """Return the generators of the domain and its coefficient domains. + + >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx + >>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ['x', 'y']) + >>> ctx.gens_recursive() + [I, x, y] + """ + return self._gens_recursive() + def is_zero(self, x) -> bool | None: """ Returns whether x is equal to the ring element 0. @@ -1096,21 +1104,21 @@ cdef class gr_fq_nmod_ctx(gr_scalar_ctx): def new(p, d, name=None) -> gr_fq_nmod_ctx: """Create a new context for finite fields. - # >>> from flint.types._gr import gr_fq_nmod_ctx - # >>> F9 = gr_fq_nmod_ctx.new(3, 2) - # >>> F9 - # gr_fq_nmod_ctx(3, 2) - # >>> F9(2) + F9(3) - # 2 - # >>> F9.characteristic() - # 3 - # >>> F9.degree() - # 2 - # >>> F9.gen() - # a - # >>> a = F9.gen() - # >>> (1 + a) ** 2 + a - # a+2 + >>> from flint.types._gr import gr_fq_nmod_ctx + >>> F9 = gr_fq_nmod_ctx.new(3, 2) + >>> F9 + gr_fq_nmod_ctx(3, 2) + >>> F9(2) + F9(3) + 2 + >>> F9.characteristic() + 3 + >>> F9.degree() + 2 + >>> F9.gen() + a + >>> a = F9.gen() + >>> (1 + a) ** 2 + a + a+2 """ cdef bytes name_b cdef char *name_c @@ -1148,21 +1156,21 @@ cdef class gr_fq_zech_ctx(gr_scalar_ctx): def new(p, d, name=None) -> gr_fq_zech_ctx: """Create a new context for finite fields with small characteristic. - # >>> from flint.types._gr import gr_fq_zech_ctx - # >>> F9 = gr_fq_zech_ctx.new(3, 2) - # >>> F9 - # gr_fq_zech_ctx(3, 2) - # >>> F9(2) + F9(3) # XXX: Is this correct? - # a^4 - # >>> F9.characteristic() - # 3 - # >>> F9.degree() - # 2 - # >>> F9.gen() - # a^1 - # >>> a = F9.gen() - # >>> (1 + a) ** 2 + a # doctest: +SKIP - # a+2 + >>> from flint.types._gr import gr_fq_zech_ctx + >>> F9 = gr_fq_zech_ctx.new(3, 2) + >>> F9 + gr_fq_zech_ctx(3, 2) + >>> F9(2) + F9(3) + a^4 + >>> F9.characteristic() + 3 + >>> F9.degree() + 2 + >>> F9.gen() + a^1 + >>> a = F9.gen() + >>> (1 + a) ** 2 + a + a^7 """ cdef bytes name_b cdef char *name_c diff --git a/src/flint/types/acb_theta.pyx b/src/flint/types/acb_theta.pyx index 3243393f..3ff57e32 100644 --- a/src/flint/types/acb_theta.pyx +++ b/src/flint/types/acb_theta.pyx @@ -3,10 +3,8 @@ from flint.types.acb cimport acb from flint.types.acb_mat cimport acb_mat from flint.flintlib.functions.acb cimport * from flint.flintlib.types.acb cimport ( - acb_mat_t, acb_mat_entry, acb_ptr, - acb_srcptr, ) from flint.flintlib.functions.acb_mat cimport * from flint.flintlib.functions.acb_theta cimport * From a99a4b1fca092091305f7fd298be980429a938ef Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 19:58:04 +0100 Subject: [PATCH 3/8] Add comments to explain missing gr_is_integer methods --- src/flint/flintlib/functions/acb_theta.pxd | 2 +- src/flint/types/_gr.pxd | 1 + src/flint/types/_gr.pyx | 2 ++ src/flint/types/acb_theta.pyx | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/flint/flintlib/functions/acb_theta.pxd b/src/flint/flintlib/functions/acb_theta.pxd index e2fa10ea..fa4a6713 100644 --- a/src/flint/flintlib/functions/acb_theta.pxd +++ b/src/flint/flintlib/functions/acb_theta.pxd @@ -54,7 +54,7 @@ cdef extern from "flint/acb_theta.h": int acb_theta_char_is_even(ulong ab, slong g) void acb_theta_char_table(ulong * ch, slong * e, const fmpz_mat_t mat, ulong ab, int all) void acb_theta_char_shuffle(acb_ptr res, const fmpz_mat_t mat, acb_srcptr th, int sqr, slong prec) - slong acb_theta_jet_nb(slong g, slong ord) + slong acb_theta_jet_nb(slong ord, slong g) slong acb_theta_jet_total_order(const slong * tup, slong g) void acb_theta_jet_tuples(slong * tups, slong ord, slong g) slong acb_theta_jet_index(const slong * tup, slong g) diff --git a/src/flint/types/_gr.pxd b/src/flint/types/_gr.pxd index d2ccd7e6..e53187f5 100644 --- a/src/flint/types/_gr.pxd +++ b/src/flint/types/_gr.pxd @@ -431,6 +431,7 @@ cdef class gr_ctx(flint_ctx): cdef inline truth_t _equal(self, gr x, gr y): return gr_equal(x.pval, y.pval, self.ctx_t) + # gr_is_integer and gr_is_rational are not defined in gr.h in FLINT <= 3.6. # @cython.final # cdef inline truth_t _is_integer(self, gr x): # return gr_is_integer(x.pval, self.ctx_t) diff --git a/src/flint/types/_gr.pyx b/src/flint/types/_gr.pyx index cf4b7b7b..4801a378 100644 --- a/src/flint/types/_gr.pyx +++ b/src/flint/types/_gr.pyx @@ -1753,6 +1753,8 @@ cdef class gr(flint_scalar): """ return truth_to_py(self._is_neg_one()) +# FLINT <= 3.6 documents gr_is_integer and gr_is_rational but does not define +# them in gr.h, so these methods cannot be enabled for the supported versions. # def is_integer(self): # """Return whether the element is an integer (may return ``None``). # diff --git a/src/flint/types/acb_theta.pyx b/src/flint/types/acb_theta.pyx index 3ff57e32..41c5b4bf 100644 --- a/src/flint/types/acb_theta.pyx +++ b/src/flint/types/acb_theta.pyx @@ -133,8 +133,8 @@ def acb_theta_jets(acb_mat z, acb_mat tau, slong ord): return acb_mat(0, 0) # Calculate the length of the jet for one characteristic - # This is the number of multi-indices (alpha) such that |alpha| < ord - cdef slong nj = acb_theta_jet_nb(g, ord) + # This is the number of multi-indices (alpha) such that |alpha| <= ord + cdef slong nj = acb_theta_jet_nb(ord, g) # Total number of characteristics cdef slong nb = 1 << (2 * g) From 87c8837b9b1b4606a94472b48461c33ef1aedfc8 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 20:32:55 +0100 Subject: [PATCH 4/8] Reenable gr_mpoly test --- src/flint/types/_gr.pyx | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/flint/types/_gr.pyx b/src/flint/types/_gr.pyx index 4801a378..48b25246 100644 --- a/src/flint/types/_gr.pyx +++ b/src/flint/types/_gr.pyx @@ -1584,24 +1584,24 @@ cdef class gr_gr_mpoly_ctx(gr_mpoly_ctx): def new(base_ring, names, order=None) -> gr_gr_mpoly_ctx: """Create a new context for dense multivariate polynomial rings. - # >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx - # >>> ZI = gr_fmpzi_ctx - # >>> R = gr_gr_mpoly_ctx.new(ZI, ['x', 'y']) - # >>> R - # gr_gr_mpoly_ctx(gr_fmpzi_ctx, ('x', 'y'), Ordering.lex) - # >>> R.base_ring - # gr_fmpzi_ctx - # >>> R.names - # ('x', 'y') - # >>> R.nvars - # 2 - # >>> R.order - # - # >>> R.gens() - # [x, y] - # >>> I, [x, y] = ZI.gen(), R.gens() - # >>> (I + x + y) ** 2 - # x^2 + 2*x*y + (2*I)*x + y^2 + (2*I)*y - 1 + >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx + >>> ZI = gr_fmpzi_ctx + >>> R = gr_gr_mpoly_ctx.new(ZI, ['x', 'y']) + >>> R + gr_gr_mpoly_ctx(gr_fmpzi_ctx, ('x', 'y'), Ordering.lex) + >>> R.base_ring + gr_fmpzi_ctx + >>> R.names + ('x', 'y') + >>> R.nvars + 2 + >>> R.order + + >>> R.gens() + [x, y] + >>> I, x, y = R.gens_recursive() + >>> (I + x + y) ** 2 + x^2 + 2*x*y + (2*I)*x + y^2 + (2*I)*y - 1 """ if order is None: order = Ordering.lex From 0f0cfb75e132dfd64b180a25e02a66d75d22e8bb Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 20:37:09 +0100 Subject: [PATCH 5/8] Reenable gr_nf tests --- src/flint/types/_gr.pyx | 64 ++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/src/flint/types/_gr.pyx b/src/flint/types/_gr.pyx index 48b25246..c439a201 100644 --- a/src/flint/types/_gr.pyx +++ b/src/flint/types/_gr.pyx @@ -1205,25 +1205,21 @@ cdef class gr_nf_ctx(gr_scalar_ctx): def new(poly) -> gr_nf_ctx: """Create a new context for number fields. - The doctests below are commented out because they crash under WASM: - - https://github.com/flintlib/python-flint/issues/319 - - # >>> from flint.types._gr import gr_nf_ctx - # >>> Qa = gr_nf_ctx.new([-2, 0, 1]) - # >>> Qa - # gr_nf_ctx(x^2 + (-2)) - # >>> Qa.modulus() - # x^2 + (-2) - # >>> a = Qa.gen() - # >>> a - # a - # >>> a**2 - # 2 - # >>> (1 + a) ** 2 - # 2*a+3 - # >>> (1 + a) / 2 - # 1/2*a+1/2 + >>> from flint.types._gr import gr_nf_ctx + >>> Qa = gr_nf_ctx.new([-2, 0, 1]) + >>> Qa + gr_nf_ctx(x^2 + (-2)) + >>> Qa.modulus() + x^2 + (-2) + >>> a = Qa.gen() + >>> a + a + >>> a**2 + 2 + >>> (1 + a) ** 2 + 2*a+3 + >>> (1 + a) / 2 + 1/2*a+1/2 """ poly = fmpq_poly(poly) return gr_nf_ctx._new(poly) @@ -1252,23 +1248,19 @@ cdef class gr_nf_fmpz_poly_ctx(gr_scalar_ctx): def new(poly) -> gr_nf_fmpz_poly_ctx: """Create a new context for number fields. - The doctests below are commented out because they crash under WASM: - - https://github.com/flintlib/python-flint/issues/319 - - # >>> from flint.types._gr import gr_nf_fmpz_poly_ctx - # >>> Qa = gr_nf_fmpz_poly_ctx.new([-2, 0, 1]) - # >>> Qa - # gr_nf_fmpz_poly_ctx(x^2 + (-2)) - # >>> Qa.modulus() - # x^2 + (-2) - # >>> a = Qa.gen() - # >>> a - # a - # >>> a**2 - # 2 - # >>> (1 + a) ** 2 - # 2*a+3 + >>> from flint.types._gr import gr_nf_fmpz_poly_ctx + >>> Qa = gr_nf_fmpz_poly_ctx.new([-2, 0, 1]) + >>> Qa + gr_nf_fmpz_poly_ctx(x^2 + (-2)) + >>> Qa.modulus() + x^2 + (-2) + >>> a = Qa.gen() + >>> a + a + >>> a**2 + 2 + >>> (1 + a) ** 2 + 2*a+3 """ poly = fmpz_poly(poly) return gr_nf_fmpz_poly_ctx._new(poly) From 7561560419d1deb334b08af6df5f56cec25598c9 Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 22:27:46 +0100 Subject: [PATCH 6/8] Simplifyacb_theta type annotations --- .github/workflows/buildwheel.yml | 6 ++++++ src/flint/types/acb_theta.pyi | 14 ++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index e026db60..1d18e10b 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -163,6 +163,12 @@ jobs: # This is probably something to do with \ vs / in paths... - if: ${{ startsWith( matrix.os , 'windows' ) }} run: | + $pkgConfig = "$env:ChocolateyInstall/bin/pkg-config.exe" + $pkgConfig = $pkgConfig.Replace('\', '/') + if (!(Test-Path $pkgConfig)) { + throw "pkg-config.exe not found at $pkgConfig" + } + echo "PKG_CONFIG=$pkgConfig" >> $env:GITHUB_ENV $pkgConfigPath = "$env:GITHUB_WORKSPACE/.local/lib/pkgconfig" $pkgConfigPath = $pkgConfigPath.Replace('\', '/') echo "PKG_CONFIG_PATH=$pkgConfigPath" >> $env:GITHUB_ENV diff --git a/src/flint/types/acb_theta.pyi b/src/flint/types/acb_theta.pyi index e5bc0239..f921720e 100644 --- a/src/flint/types/acb_theta.pyi +++ b/src/flint/types/acb_theta.pyi @@ -1,18 +1,8 @@ from __future__ import annotations -from typing import Protocol - from flint.types.acb_mat import acb_mat -class _AcbThetaFunc(Protocol): - def __call__(self, z: acb_mat, tau: acb_mat, square: bool | int = False) -> acb_mat: ... - - -class _AcbThetaJetsFunc(Protocol): - def __call__(self, z: acb_mat, tau: acb_mat, ord: int) -> acb_mat: ... - - -acb_theta: _AcbThetaFunc | None +def acb_theta(z: acb_mat, tau: acb_mat, square: bool | int = False) -> acb_mat: ... -acb_theta_jets: _AcbThetaJetsFunc | None +def acb_theta_jets(z: acb_mat, tau: acb_mat, ord: int) -> acb_mat: ... From ddbe5316c25ca365ff718571671503aaa310edea Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sat, 29 Aug 2026 22:50:40 +0100 Subject: [PATCH 7/8] Remove cruft for building old dependency versions --- bin/build_dependencies_unix.sh | 172 +-------------------------- bin/build_variables.sh | 7 +- bin/cibw_before_all_linux_aarch64.sh | 1 - bin/cibw_before_all_linux_x86_64.sh | 1 - bin/cibw_before_all_macosx_arm64.sh | 1 - bin/cibw_before_all_macosx_x86_64.sh | 1 - bin/rtd_before_all_linux.sh | 1 - 7 files changed, 7 insertions(+), 177 deletions(-) diff --git a/bin/build_dependencies_unix.sh b/bin/build_dependencies_unix.sh index 7a38f8c0..3f4ae879 100755 --- a/bin/build_dependencies_unix.sh +++ b/bin/build_dependencies_unix.sh @@ -5,17 +5,6 @@ set -o errexit -# ------------------------------------------------------------------------- # -# # -# Supported options: # -# # -# --gmp gmp - build based on GMP (default) # -# --gmp mpir - build based on MPIR (no longer works) # -# --host - set the host (target) for GMP build # -# --patch-gmp-arm64 - apply patch to GMP for OSX arm64 # -# # -# ------------------------------------------------------------------------- # - SKIP_GMP=no SKIP_MPFR=no PATCH_GMP_C23=no @@ -25,9 +14,6 @@ GMP_FAT_ARG="--enable-fat" GMP_ASSEMBLY_ARG= HOST_ARG= -USE_GMP=gmp -PATCH_GMP_ARM64=no -BUILD_ARB=no USE_GMP_GITHUB_MIRROR=no while [[ $# -gt 0 ]] @@ -35,7 +21,7 @@ do key="$1" case $key in -h|--help) - echo "bin/download_dependencies.sh [options]" + echo "bin/build_dependencies_unix.sh [options]" echo echo "Build local installs of python-flint's dependencies." echo @@ -45,15 +31,10 @@ do echo " --skip-gmp - skip building GMP" echo " --skip-mpfr - skip building MPFR" echo " --disable-assembly - disable GMP assembly routines" + echo " --patch-C23 - apply patch to GMP 6.3.0 for C23 compatibility" echo " --patch-ldd - patch flint shared linking for mingw on arm64" echo " --patch-immintrin - patch flint arm64 msvc header to avoid immintrin.h" echo - echo "Legacy options:" - echo " --gmp gmp - build based on GMP (default)" - echo " --gmp mpir - build based on MPIR (no longer works)" - echo " --patch-gmp-arm64 - apply patch to GMP 6.2.1 for OSX arm64" - echo " --patch-C23 - apply patch to GMP 6.3.0 for C23 compatibility" - echo " --arb - build Arb (only needed for flint < 3.0.0)" echo exit ;; @@ -64,23 +45,6 @@ do shift shift ;; - --gmp) - # e.g. --gmp gmp or --gmp mpir - # The mpir build no longer works because the download fails. - USE_GMP="$2" - if [[ "$USE_GMP" != "gmp" && "$USE_GMP" != "mpir" ]]; then - echo "--gmp option should be gmp or mpir" - exit 1 - fi - shift - shift - ;; - --arb) - # With flint >= 3.0.0 Arb is included so we do not need to build it - # separately. Pass --arb if building for older versions of flint. - BUILD_ARB=yes - shift - ;; --skip-gmp) # If you already have a local install of GMP you can pass --skip-gmp # to skip building it. @@ -99,12 +63,6 @@ do GMP_ASSEMBLY_ARG="--disable-assembly" shift ;; - --patch-gmp-arm64) - # Needed only for GMP 6.2.1 on OSX arm64 (Apple M1) hardware - # As of GMP 6.3.0 this patch is no longer needed - PATCH_GMP_ARM64=yes - shift - ;; --patch-C23) # Patch GMP 6.3.0 for newer gcc versions PATCH_GMP_C23=yes @@ -151,21 +109,13 @@ cd src # # # ------------------------------------------------------------------------- # -if [ "$USE_GMP" = "gmp" ]; then - - # ----------------------------------------------------------------------- # - # # - # GMP # - # # - # ----------------------------------------------------------------------- # - - if [ "$SKIP_GMP" = "yes" ]; then +if [ "$SKIP_GMP" = "yes" ]; then echo echo -------------------------------------------- echo " skipping GMP" echo -------------------------------------------- echo - else +else echo echo -------------------------------------------- echo " building GMP" @@ -183,20 +133,6 @@ if [ "$USE_GMP" = "gmp" ]; then tar xf gmp-$GMPVER.tar.xz cd gmp-$GMPVER - # - # See https://github.com/aleaxit/gmpy/issues/350 - # - # We need to patch GMP for OSX arm64 (Apple M1) hardware. This patch is - # from the GMP repo but was applied after the release of GMP 6.2.1. - # This patch is no longer needed for GMP 6.3.0. - # - if [ "$PATCH_GMP_ARM64" = "yes" ]; then - echo - echo -------------------------------------------- - echo " patching GMP" - echo -------------------------------------------- - patch -N -Z -p0 < ../../../bin/patch-arm64.diff - fi # # https://github.com/msys2/MSYS2-packages/issues/5499 # @@ -227,59 +163,6 @@ if [ "$USE_GMP" = "gmp" ]; then cd .. - fi - - FLINTARB_WITHGMP="--with-gmp=$PREFIX" - -else - - # ----------------------------------------------------------------------- # - # # - # YASM (needed to build MPIR) # - # # - # ----------------------------------------------------------------------- # - - curl -O http://www.tortall.net/projects/yasm/releases/yasm-$YASMVER.tar.gz - tar xf yasm-$YASMVER.tar.gz - cd yasm-$YASMVER - ./configure --prefix=$PREFIX - make -j6 - make install - cd .. - - # ----------------------------------------------------------------------- # - # # - # MPIR # - # # - # ----------------------------------------------------------------------- # - - # - # The mpir.org domain has expired and no longer hosts the source code so the - # call to curl below will fail. - # We could try to download from https://github.com/wbhart/mpir/releases. - # - # Ultimately it seems that MPIR is no longer maintained though so for now - # this remains unfixed. - # - - >&2 echo "MPIR build of python_flint is no longer supported" - exit 1 - - curl -O http://mpir.org/mpir-$MPIRVER.tar.bz2 - tar xf mpir-$MPIRVER.tar.bz2 - cd mpir-$MPIRVER - ./configure --prefix=$PREFIX\ - --with-yasm=$PREFIX/bin/yasm\ - --enable-fat\ - --enable-shared=yes\ - --enable-static=no\ - --enable-gmpcompat - make -j6 - make install - cd .. - - FLINTARB_WITHGMP="--with-mpir=$PREFIX" - fi # ------------------------------------------------------------------------- # @@ -354,7 +237,7 @@ cd flint-$FLINTVER ./bootstrap.sh ./configure --prefix=$PREFIX\ --host=$HOST_ARG\ - $FLINTARB_WITHGMP\ + --with-gmp=$PREFIX\ --with-mpfr=$PREFIX\ --disable-static\ --disable-debug @@ -362,41 +245,6 @@ cd flint-$FLINTVER make install cd .. -# ------------------------------------------------------------------------- # -# # -# ARB # -# # -# ------------------------------------------------------------------------- # - -if [ "$BUILD_ARB" = "yes" ]; then - - echo - echo -------------------------------------------- - echo " building Arb" - echo -------------------------------------------- - echo - - curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz - mv $ARBVER.tar.gz arb-$ARBVER.tar.gz - tar xf arb-$ARBVER.tar.gz - cd arb-$ARBVER - ./configure --prefix=$PREFIX\ - --with-flint=$PREFIX\ - $FLINTARB_WITHGMP\ - --with-mpfr=$PREFIX\ - --disable-static - make -j6 - make install - # - # Set PATH so that DLLs are picked up on Windows. - # - PATH=$PATH:$PREFIX/lib:$PREFIX/bin \ - ARB_TEST_MULTIPLIER=0.1 \ - # Skip Arb tests now because they are slow. - # make check - cd .. -fi - # ------------------------------------------------------------------------- # # # # Done! # @@ -414,11 +262,7 @@ echo Versions: if [ "$SKIP_GMP" = "yes" ]; then echo GMP: skipped else - if [[ $USE_GMP = "gmp" ]]; then - echo GMP: $GMPVER - else - echo MPIR: $MPIRVER - fi + echo GMP: $GMPVER fi if [ "$SKIP_MPFR" = "yes" ]; then @@ -428,10 +272,6 @@ else fi echo Flint: $FLINTVER - -if [ "$BUILD_ARB" = "yes" ]; then - echo Arb: $ARBVER -fi echo echo ----------------------------------------------------------------------- echo diff --git a/bin/build_variables.sh b/bin/build_variables.sh index 7616aa53..71774a75 100644 --- a/bin/build_variables.sh +++ b/bin/build_variables.sh @@ -11,12 +11,7 @@ PREFIX=$(pwd)/.local -ARBVER=2.23.0 # Not needed with flint >= 3.0.0 (Arb is included in flint) - -YASMVER=1.3.0 # Only needed for MPIR -MPIRVER=3.0.0 # MPIR build no longer works (not clear where to download from) - -# These are the actual dependencies used (at least by default): +# Versions of the dependencies used by python-flint: GMPVER=6.3.0 MPFRVER=4.2.2 FLINTVER=3.6.0 diff --git a/bin/cibw_before_all_linux_aarch64.sh b/bin/cibw_before_all_linux_aarch64.sh index 3538bef5..9237bed0 100755 --- a/bin/cibw_before_all_linux_aarch64.sh +++ b/bin/cibw_before_all_linux_aarch64.sh @@ -4,6 +4,5 @@ set -e yum install -y xz bin/build_dependencies_unix.sh\ - --gmp gmp\ --host aarch64-pc-linux-gnu\ --use-gmp-github-mirror diff --git a/bin/cibw_before_all_linux_x86_64.sh b/bin/cibw_before_all_linux_x86_64.sh index 36d5f844..99a5cea1 100755 --- a/bin/cibw_before_all_linux_x86_64.sh +++ b/bin/cibw_before_all_linux_x86_64.sh @@ -4,6 +4,5 @@ set -e yum install -y xz bin/build_dependencies_unix.sh\ - --gmp gmp\ --host x86_64-pc-linux-gnu\ --use-gmp-github-mirror diff --git a/bin/cibw_before_all_macosx_arm64.sh b/bin/cibw_before_all_macosx_arm64.sh index 3f98f67a..52109d32 100755 --- a/bin/cibw_before_all_macosx_arm64.sh +++ b/bin/cibw_before_all_macosx_arm64.sh @@ -8,6 +8,5 @@ export LDFLAGS=" -arch arm64" brew install automake libtool bin/build_dependencies_unix.sh\ - --gmp gmp\ --host aarch64-apple-darwin\ --use-gmp-github-mirror diff --git a/bin/cibw_before_all_macosx_x86_64.sh b/bin/cibw_before_all_macosx_x86_64.sh index 15810857..19e9d523 100755 --- a/bin/cibw_before_all_macosx_x86_64.sh +++ b/bin/cibw_before_all_macosx_x86_64.sh @@ -5,6 +5,5 @@ set -e brew install automake libtool bin/build_dependencies_unix.sh\ - --gmp gmp\ --host x86_64-apple-darwin\ --use-gmp-github-mirror diff --git a/bin/rtd_before_all_linux.sh b/bin/rtd_before_all_linux.sh index ff4cddba..60b7a9a4 100755 --- a/bin/rtd_before_all_linux.sh +++ b/bin/rtd_before_all_linux.sh @@ -3,6 +3,5 @@ apt-get install xz-utils bin/build_dependencies_unix.sh\ - --gmp gmp\ --host x86_64-pc-linux-gnu\ --use-gmp-github-mirror From b9a883992f56bdc5110780d954b6347d461b957b Mon Sep 17 00:00:00 2001 From: Oscar Benjamin Date: Sun, 30 Aug 2026 01:30:51 +0100 Subject: [PATCH 8/8] Try simplifying the pkgconfig handling on Windows --- .github/workflows/buildwheel.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 1d18e10b..000a304d 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -155,20 +155,18 @@ jobs: update: true # Install pkgconfig on Windows from choco rather than from msys and - # avoid using the Strawberry one. + # put its shim ahead of the Strawberry one on PATH. - if: ${{ startsWith( matrix.os , 'windows' ) }} - run: choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite + name: Install pkg-config + run: | + choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite + echo "$env:ChocolateyInstall/bin" >> $env:GITHUB_PATH - # We have to set this here rather than in the cibuildwheel config - # This is probably something to do with \ vs / in paths... - if: ${{ startsWith( matrix.os , 'windows' ) }} + name: Configure pkg-config run: | - $pkgConfig = "$env:ChocolateyInstall/bin/pkg-config.exe" - $pkgConfig = $pkgConfig.Replace('\', '/') - if (!(Test-Path $pkgConfig)) { - throw "pkg-config.exe not found at $pkgConfig" - } - echo "PKG_CONFIG=$pkgConfig" >> $env:GITHUB_ENV + Get-Command pkg-config + pkg-config --version $pkgConfigPath = "$env:GITHUB_WORKSPACE/.local/lib/pkgconfig" $pkgConfigPath = $pkgConfigPath.Replace('\', '/') echo "PKG_CONFIG_PATH=$pkgConfigPath" >> $env:GITHUB_ENV