From 0c000461941abd0462d4ddb893a33801fe49aae9 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 14 May 2024 10:02:43 +0200 Subject: [PATCH 1/2] Avoid symbol clashes in plot_expressions (#2440) Ignore sympy constants when sympifying expression strings to avoid clashes with sympy.*. --- python/sdist/amici/numpy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/sdist/amici/numpy.py b/python/sdist/amici/numpy.py index 9aa03fc2dd..4f659c0b45 100644 --- a/python/sdist/amici/numpy.py +++ b/python/sdist/amici/numpy.py @@ -13,7 +13,7 @@ import amici import numpy as np import sympy as sp - +from sympy.abc import _clash from . import ExpData, ExpDataPtr, Model, ReturnData, ReturnDataPtr StrOrExpr = Union[str, sp.Expr] @@ -497,7 +497,7 @@ def evaluate(expr: StrOrExpr, rdata: ReturnDataView) -> np.array: from sympy.utilities.lambdify import lambdify if isinstance(expr, str): - expr = sp.sympify(expr) + expr = sp.sympify(expr, locals=_clash) arg_names = list(sorted(expr.free_symbols, key=lambda x: x.name)) func = lambdify(arg_names, expr, "numpy") From a63b016f316e7ab95eca2a2b0a9d0119448daf61 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 14 May 2024 14:31:41 +0200 Subject: [PATCH 2/2] Pin cmake_build_extension==0.5.1 (#2446) Missed one location before. Fixes #2442. --- scripts/installAmiciSource.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/installAmiciSource.sh b/scripts/installAmiciSource.sh index c074c89d46..514926773f 100755 --- a/scripts/installAmiciSource.sh +++ b/scripts/installAmiciSource.sh @@ -33,7 +33,7 @@ fi export PYTHON_EXECUTABLE="${AMICI_PATH}/venv/bin/python" python -m pip install --upgrade pip wheel -python -m pip install --upgrade pip setuptools cmake_build_extension numpy +python -m pip install --upgrade pip setuptools cmake_build_extension==0.5.1 numpy python -m pip install git+https://github.com/FFroehlich/pysb@fix_pattern_matching # pin to PR for SPM with compartments AMICI_BUILD_TEMP="${AMICI_PATH}/python/sdist/build/temp" \ python -m pip install --verbose -e "${AMICI_PATH}/python/sdist[petab,test,vis]" --no-build-isolation