Skip to content

Commit 5fe5344

Browse files
Sympy 1 10 (#237)
Fixed tests to pass with sympy 1.10 and required latest cellmlmanip, which also workes with sympy1.10. Updated sympy requirement to be >=1.9, < 1.11
1 parent 4ece133 commit 5fe5344

File tree

109 files changed

+44123
-8485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+44123
-8485
lines changed

RELEASE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# Release 0.9.6
2+
- Fixed tests to pass with sympy 1.10 and required latest cellmlmanip, which also workes with sympy1.10. Updated sympy requirement to be >=1.9, < 1.11
3+
14
# Release 0.9.5
25
- Corrected a type in the generated output for `--rush-larsen-c`
36
- Updated the help text to no longer imply that CellML files can be converted from remote URIs (a local file is required)
4-
- Fixed required sympy version to be < 1.10 since the jacobean generation has in sympy1.10 changed and makes chaste_codegen tests fail
7+
- Fixed required sympy version to be < 1.9 since the jacobean generation has in sympy1.10 changed and makes chaste_codegen tests fail
58

69
# Release 0.9.4
710
- This version drops python 3.5 support. The reason for this is python 3.5 is end of life and the chase project will soon be dropping support.

chaste_codegen/_chaste_printer.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,19 @@ def _print_ternary(self, cond, expr):
140140
parts += ') : ('
141141
return parts
142142

143+
def _print_IntegerConstant(self, expr):
144+
return cxxcode(int(expr), standard='C++11')
145+
143146
def _print_float(self, expr):
144147
""" Handles ``float``s. """
145-
return cxxcode(expr, standard='C++11')
148+
if expr.is_integer():
149+
return cxxcode(int(expr), standard='C++11')
150+
else:
151+
return cxxcode(expr, standard='C++11')
152+
153+
def _print_int(self, expr):
154+
""" Handles ``ints``s. """
155+
return cxxcode(int(expr), standard='C++11')
146156

147157
def _print_ITE(self, expr):
148158
""" Handles ITE (if then else) objects by rewriting them as Piecewise """

chaste_codegen/_partial_eval.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
Float,
66
Piecewise,
77
cse,
8+
exp,
89
piecewise_fold,
910
)
11+
from sympy.core import Symbol
12+
13+
from chaste_codegen._math_functions import exp_
1014

1115

1216
def get_usage_count(equations):
@@ -32,10 +36,12 @@ def fold_piecewises(expr):
3236
# Since piecewise_fold hangs with some complicated nestings, due to simplification we use the following workaround:
3337
# First extract common terms, perform piecewise_fold, re-insert the common terms
3438
# see: https://github.com/sympy/sympy/issues/20850
39+
expr = expr.replace(exp, exp_)
3540
common_terms, expr = cse(expr)
3641
expr = piecewise_fold(expr[0])
3742
for term, ex in reversed(common_terms):
3843
expr = expr.xreplace({term: ex})
44+
expr = expr.replace(exp_, exp)
3945
return expr
4046

4147

@@ -45,11 +51,11 @@ def partial_eval(equations, required_lhs, keep_multiple_usages=True):
4551
:param equations: the equations to partially evaluate
4652
:param required_lhs: variables which which the defining equation is kept and not substituted
4753
:param keep_multiple_usages: if a variable is used multiple times keep its defining equation
48-
:return: the equations wit defining equations substituted in to create a minimal set of equations
54+
:return: the equations with defining equations substituted in to create a minimal set of equations
4955
"""
5056

5157
assert all(map(lambda eq: isinstance(eq, Eq), equations)), "Expecting equations to be a collection of equations"
52-
assert all(map(lambda v: isinstance(v, Variable) or isinstance(v, Derivative), required_lhs)), \
58+
assert all(map(lambda v: isinstance(v, (Variable, Derivative, Symbol)), required_lhs)), \
5359
"Expecting required_lhs to be a collection of variables or derivatives"
5460

5561
evaluated_eqs = []
@@ -71,6 +77,5 @@ def partial_eval(equations, required_lhs, keep_multiple_usages=True):
7177
if not keep_multiple_usages:
7278
subs_dict[eq.lhs] = new_rhs
7379
evaluated_eqs.append(Eq(eq.lhs, new_rhs))
74-
7580
return evaluated_eqs
7681

chaste_codegen/data/tests/chaste_reference_models/BE/dynamic_courtemanche_ramirez_nattel_1998.cpp

Lines changed: 183 additions & 181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/dynamic_courtemanche_ramirez_nattel_1998.cpp_alt

Lines changed: 993 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/grandi_pasqualini_bers_2010_ssBackwardEuler.cpp

Lines changed: 396 additions & 402 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/grandi_pasqualini_bers_2010_ssBackwardEuler.cpp_alt

Lines changed: 2275 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/li_mouse_2010.cpp

Lines changed: 325 additions & 335 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/li_mouse_2010.cpp_alt

Lines changed: 1833 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/sachse_moreno_abildskov_2008_b.cpp

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chaste_codegen/data/tests/chaste_reference_models/BE/test_piecewises_be.cpp

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)