Skip to content
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
35 changes: 34 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The pre-commit hooks (ruff, file checks, no em dashes) and the test suite on a source build, on Linux,
# macOS and Windows with the oldest and the newest supported Python.
# macOS and Windows with the oldest and the newest supported Python, each with msolve built from source.
name: CI

# master moves only by fast-forward to a commit its pull request has tested
Expand Down Expand Up @@ -41,7 +41,40 @@ jobs:
allow-prereleases: true
- name: Install from source
run: python -m pip install ".[test]"
# msolve per runner image, rebuilt when the build script or the version changes
- name: Cache msolve
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/symident-cache
key: msolve-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('src/symident/tools/build-msolve.sh', 'src/symident/install.py') }}
- name: Build msolve
if: runner.os != 'Windows'
env:
SYMIDENT_CACHE: ${{ runner.temp }}/symident-cache
run: python -c "from symident import install; install.find_msolve()[0] or install.install_msolve(ask=False, jobs=4)"
# install_msolve() does not build on Windows: the same script under MSYS2, passed on by SYMIDENT_MSOLVE
- uses: msys2/setup-msys2@3c51bf698df1e37b2261f53cb67797b97761185c # v2.34.0
if: runner.os == 'Windows'
with:
msystem: UCRT64
install: mingw-w64-ucrt-x86_64-gcc make m4 curl tar xz
- name: Build msolve on Windows
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
export SYMIDENT_LIBS_CACHE="$(cygpath -u "$RUNNER_TEMP")/symident-cache" SYMIDENT_JOBS=4 CC=gcc
prefix="$SYMIDENT_LIBS_CACHE/deps-msolve-0.11.0"
[ -f "$prefix/.msolve-complete" ] || sh src/symident/tools/build-msolve.sh
echo "SYMIDENT_MSOLVE=$(cygpath -w "$prefix/bin/msolve.exe")" >> "$GITHUB_ENV"
cygpath -w /ucrt64/bin >> "$GITHUB_PATH"
# the msolve tests skip where msolve is missing; here it must be found
- name: Check msolve
env:
SYMIDENT_CACHE: ${{ runner.temp }}/symident-cache
run: python -c "from symident import install; p, s = install.find_msolve(); assert p, 'no msolve'; print(p, s)"
# outside the checkout, so that the tests import the installed package
- name: Tests
working-directory: ${{ runner.temp }}
env:
SYMIDENT_CACHE: ${{ runner.temp }}/symident-cache
run: python -m pytest -q -n auto "${{ github.workspace }}/tests"
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# symident 0.18.4

* The counts modulo a prime over the reduced Gröbner basis pass the coefficients to msolve reduced
modulo the prime, so they are the same on Windows as on Linux and macOS; the check of a resting
state names the error bound on every platform.
* `memory` of `discrete()` and of `global_options` limits the address space of msolve on Linux only;
macOS does not enforce the limit and Windows has none.
* `install_msolve()` retries each download three times and takes GMP and MPFR from a GNU mirror
when ftp.gnu.org does not answer.
* The tests of the continuous integration run with msolve built from source on Linux, macOS and
Windows, msolve kept in the cache of each runner image.

# symident 0.18.3

## Global analysis
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/global.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Calling the global analysis
second step on a result of a local detection. ``global_options`` passes the arguments of
:meth:`~symident.Symmetries.discrete`: ``order``, the highest Taylor coefficient of the
observables, ``points``, the number of random points of the count in the domain, ``memory``, the
address space of one call of msolve, ``experiments``, the count of several experiments, and the
address space of one call of msolve (on Linux), ``experiments``, the count of several experiments, and the
work limits ``msolve_work`` (the work of the F4 rounds of one msolve call, 1e10),
``msolve_terms`` (terms of one system given to msolve, 1e5), ``search_entries`` (entries of the
matrices over :math:`\mathbb{F}_p` the exact search reduces, 2e9) and ``elimination_terms`` (terms
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"

[project]
name = "symident"
version = "0.18.3"
version = "0.18.4"
description = "Structural identifiability of ODE models by Lie symmetries over finite fields"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion src/symident/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"install_msolve",
"switches",
]
__version__ = "0.18.3"
__version__ = "0.18.4"
2 changes: 1 addition & 1 deletion src/symident/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def discrete(
Threads of msolve.
memory : float, optional
GiB of address space one call of msolve may take, 8 by default; past it the call
fails.
fails. The limit applies on Linux; macOS does not enforce it and Windows has none.
experiments : bool or int, optional
The count of several experiments with shared parameters and free starts, projected
onto the parameters and starts of the first, which bounds the fiber of a model with
Expand Down
6 changes: 6 additions & 0 deletions src/symident/detection/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,10 @@ def find(i):
return list(out.values())


# an integer literal, not a digit of a name
_INT = re.compile(r"(?<![A-Za-z_\d])\d+")


def _gb_count(names, p, eqs, sep=(), cap=5000, exact=False, dims=None):
"""The number of points of the ideal of `eqs` in `names` + si_w over the algebraic closure of GF(p) with
distinct values of the coordinates `sep`; None where it is not finite, the quotient above `cap`, or on failure.
Expand All @@ -2111,6 +2115,8 @@ def _gb_count(names, p, eqs, sep=(), cap=5000, exact=False, dims=None):
if work.msolve_too_large(names, eqs):
_failed(kind="size")
return None
# the coefficients modulo p: msolve reads integers past the width of a C long wrongly on Windows
eqs = [_INT.sub(lambda m: str(int(m.group()) % p), e) for e in eqs]
with tempfile.TemporaryDirectory() as td:
fi, fo = os.path.join(td, "in.ms"), os.path.join(td, "out.ms")
with open(fi, "w") as fh:
Expand Down
22 changes: 16 additions & 6 deletions src/symident/tools/build-msolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,45 @@ rm -rf "$WORK" "$PREFIX/.msolve-complete"
mkdir -p "$WORK" "$PREFIX/bin"
cd "$WORK"

# fetch OUT URL...: the first URL that answers, each tried three times
fetch() {
if command -v curl >/dev/null 2>&1; then curl -fsSL -o "$2" "$1"
else wget -q -O "$2" "$1"; fi
out=$1; shift
for url in "$@"; do
if command -v curl >/dev/null 2>&1; then
curl -fsSL --retry 3 --connect-timeout 30 -o "$out" "$url" && return 0
else
wget -q --tries=3 --timeout=30 -O "$out" "$url" && return 0
fi
done
return 1
}
# GNU sources from the main server or a mirror
gnu() { fetch "$2" "https://ftp.gnu.org/gnu/$1" "https://ftpmirror.gnu.org/gnu/$1"; }
step() { echo "==> $*" >&2; }

step "GMP $GMP"
fetch "https://ftp.gnu.org/gnu/gmp/gmp-$GMP.tar.xz" gmp.tar.xz
gnu "gmp/gmp-$GMP.tar.xz" gmp.tar.xz
tar xf gmp.tar.xz
# generic build triples: the binary runs on every CPU of the architecture, not only on the
# one that built it
(cd "gmp-$GMP" && ./configure --build="$(sh ./configfsf.guess)" --prefix="$PREFIX" \
--disable-shared --enable-static --with-pic >&2 && make -j"$JOBS" >&2 && make install >&2)

step "MPFR $MPFR"
fetch "https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFR.tar.xz" mpfr.tar.xz
gnu "mpfr/mpfr-$MPFR.tar.xz" mpfr.tar.xz
tar xf mpfr.tar.xz
(cd "mpfr-$MPFR" && ./configure --prefix="$PREFIX" --disable-shared --enable-static \
--with-pic --with-gmp="$PREFIX" >&2 && make -j"$JOBS" >&2 && make install >&2)

step "FLINT $FLINT"
fetch "https://github.com/flintlib/flint/releases/download/v$FLINT/flint-$FLINT.tar.gz" flint.tar.gz
fetch flint.tar.gz "https://github.com/flintlib/flint/releases/download/v$FLINT/flint-$FLINT.tar.gz"
tar xzf flint.tar.gz
(cd "flint-$FLINT" && ./configure --build="$(sh config/configfsf.guess)" --prefix="$PREFIX" \
--disable-shared --enable-static --with-pic --with-gmp="$PREFIX" --with-mpfr="$PREFIX" >&2 &&
make -j"$JOBS" >&2 && make install >&2)

step "msolve $MSOLVE"
fetch "https://github.com/algebraic-solving/msolve/archive/refs/tags/v$MSOLVE.tar.gz" msolve.tar.gz
fetch msolve.tar.gz "https://github.com/algebraic-solving/msolve/archive/refs/tags/v$MSOLVE.tar.gz"
tar xzf msolve.tar.gz
cd "msolve-$MSOLVE"
cat > config.h <<EOF
Expand Down
4 changes: 3 additions & 1 deletion tests/test_discrete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Discrete symmetries: the other points of the domain with the output of a generic one."""

import math
import sys
from fractions import Fraction

import pytest
Expand Down Expand Up @@ -910,7 +911,7 @@ def test_the_symbols_of_the_package_hold_no_clock():
hits = [
f"{p.name}:{n}"
for p in src.rglob("*.py")
for n, line in enumerate(p.read_text().splitlines(), 1)
for n, line in enumerate(p.read_text(encoding="utf-8").splitlines(), 1)
if pat.search(line)
]
assert hits == []
Expand Down Expand Up @@ -1248,6 +1249,7 @@ def count(fib, point, p):
assert discrete.choose_order(series, True, 1, 20)[2] is None and given == [[2, 4]]


@pytest.mark.skipif(sys.platform != "linux", reason="the address space limit applies on Linux only")
def test_a_count_that_msolve_ends_out_of_memory_is_named_so(monkeypatch):
from symident.detection import fieldproof

Expand Down
Loading