From b35263b0b2bb361c7d44984b1a49ed46e4bd2208 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Mon, 2 Dec 2024 15:48:38 +0100 Subject: [PATCH 1/2] Fix issue with reserved symbols --- python/nmodl/ode.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/nmodl/ode.py b/python/nmodl/ode.py index f34c9d026..7d09fd156 100644 --- a/python/nmodl/ode.py +++ b/python/nmodl/ode.py @@ -50,6 +50,8 @@ "loggamma", "digamma", "trigamma", + # sympy.assumptions.ask.ask + "ask", ] @@ -636,6 +638,11 @@ def differentiate2c( sympy_vars = {str(var): make_symbol(var) for var in vars} sympy_vars[dependent_var] = x + expression, _ = search_and_replace_protected_identifiers_to_sympy( + [expression], [], [] + ) + expression = expression[0] + # parse string into SymPy equation expr = sp.sympify(expression, locals=sympy_vars) @@ -709,4 +716,6 @@ def differentiate2c( pass # return result as C code in NEURON format - return sp.ccode(diff.evalf(), user_functions=custom_fcts) + result = sp.ccode(diff.evalf(), user_functions=custom_fcts) + + return search_and_replace_protected_identifiers_from_sympy([result], [])[0] From 4a075a96f8262fa4b09cacc5e82abe60dd7b10c0 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Tue, 3 Dec 2024 08:51:33 +0100 Subject: [PATCH 2/2] More symbols --- python/nmodl/ode.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/nmodl/ode.py b/python/nmodl/ode.py index 7d09fd156..0ab894acf 100644 --- a/python/nmodl/ode.py +++ b/python/nmodl/ode.py @@ -52,6 +52,10 @@ "trigamma", # sympy.assumptions.ask.ask "ask", + # sympy.series.order.Order + "O", + # alias for sympy.core.evalf + "N", ]