Skip to content

Commit

Permalink
Merge pull request #343 from nanglo123/fix_sympy_tests
Browse files Browse the repository at this point in the history
Adjust test that are affected by the sympy 1.13 update
  • Loading branch information
bgyori authored Jul 10, 2024
2 parents 5d1110c + 70bb056 commit 65ff736
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest
from collections import Counter
from copy import deepcopy as _d
from fractions import Fraction

import sympy

Expand Down Expand Up @@ -189,8 +190,8 @@ def test_stratify(self):
self.assertIn(key, actual.initials, msg="")
# Cannot use .args[0] here as .args[0] not a primitive data type
self.assertEqual(
SympyExprStr(float(str(sir_parameterized.initials[original_name].expression)) / len(cities)),
actual.initials[key].expression,
float(SympyExprStr(float(sir_parameterized.initials[original_name].expression.__str__()) / len(cities)).__str__()),
float(Fraction(actual.initials[key].expression.__str__())),
msg=f"initial value was not copied from original compartment "
f"({original_name}) to stratified compartment ({key})"
)
Expand Down Expand Up @@ -225,8 +226,8 @@ def test_stratify_w_name_map(self):
self.assertIn(key, actual.initials, msg=f"Key '{key}' not in initials")
# Cannot use .args[0] here as .args[0] not a primitive data type
self.assertEqual(
SympyExprStr(float(str(sir_parameterized.initials[original_name].expression)) / len(cities)),
actual.initials[key].expression,
float(SympyExprStr(float(sir_parameterized.initials[original_name].expression.__str__()) / len(cities)).__str__()),
float(Fraction(actual.initials[key].expression.__str__())),
msg=f"initial value was not copied from original compartment "
f"({original_name}) to stratified compartment ({key})"
)
Expand Down Expand Up @@ -261,8 +262,8 @@ def test_stratify_w_client_mapping(self):
self.assertIn(key, actual.initials, msg=f"Key '{key}' not in initials")
# Cannot use .args[0] here as .args[0] not a primitive data type
self.assertEqual(
SympyExprStr(float(str(sir_parameterized.initials[original_name].expression)) / len(cities)),
actual.initials[key].expression,
float(SympyExprStr(float(sir_parameterized.initials[original_name].expression.__str__()) / len(cities)).__str__()),
float(Fraction(actual.initials[key].expression.__str__())),
msg=f"initial value was not copied from original compartment "
f"({original_name}) to stratified compartment ({key})"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_petri_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def test_petri_reverse_parameterized():
susceptible.name
assert tm.initials['susceptible_population'].concept.identifiers == \
susceptible.identifiers
assert SympyExprStr(1).equals(tm.initials['susceptible_population'].expression)
assert SympyExprStr(1.0) == tm.initials['susceptible_population'].expression
assert tm.templates[0].rate_law
assert tm.templates[1].rate_law

0 comments on commit 65ff736

Please sign in to comment.