From 508dc1fa6585a47396a564224b53b5845a724f78 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 13 May 2024 11:28:01 +0200 Subject: [PATCH] Avoid symbol clashes in plot_expressions 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")