Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate sbmlmath testing #241

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ install_requires =
typing_extensions
networkx
tqdm
sbmlmath; python_version >= "3.10"

zip_safe = false
include_package_data = True
Expand Down
25 changes: 17 additions & 8 deletions tests/test_modeling/test_askenet_ops.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import unittest
import requests
import pytest
from copy import deepcopy as _d
from mira.modeling.askenet.ops import *
from sympy import *
from mira.metamodel.io import mathml_to_expression
from mira.metamodel.templates import Concept

try:
import sbmlmath
except ImportError:
sbmlmath_available = False
else:
sbmlmath_available = True


SBMLMATH_REQUIRED = unittest.skipUnless(sbmlmath_available, reason="SBMLMath package is not available")


class TestAskenetOperations(unittest.TestCase):
"""A test case for operations on template models."""
Expand Down Expand Up @@ -188,7 +197,7 @@ def test_remove_observable_or_parameter(self):

self.assertEqual(old_obs['id'], new_obs['id'])

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
def test_add_observable(self):
amr = _d(self.sir_amr)
new_id = 'testinf'
Expand All @@ -207,7 +216,7 @@ def test_add_observable(self):
self.assertEqual(xml_expression, new_observable_dict[new_id]['expression_mathml'])
self.assertEqual(sstr(mathml_to_expression(xml_expression)), new_observable_dict[new_id]['expression'])

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
def test_replace_parameter_id(self):
old_id = 'beta'
new_id = 'TEST'
Expand Down Expand Up @@ -311,7 +320,7 @@ def test_remove_transition(self):
for new_transition in new_model_transition:
self.assertNotEquals(removed_transition, new_transition['id'])

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
def test_add_transition(self):
test_subject = Concept(name="test_subject", identifiers={"ido": "0000511"})
test_outcome = Concept(name="test_outcome", identifiers={"ido": "0000592"})
Expand Down Expand Up @@ -404,7 +413,7 @@ def test_add_transition(self):
natural_degradation_rates_dict[new_transition_id]['expression'])
self.assertIn(test_subject.name, natural_degradation_states_dict)

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
def test_replace_rate_law_sympy(self):
transition_id = 'inf'
target_expression_xml_str = '<apply><plus/><ci>X</ci><cn>8</cn></apply>'
Expand All @@ -419,7 +428,7 @@ def test_replace_rate_law_sympy(self):
self.assertEqual(sstr(target_expression_sympy), new_rate['expression'])
self.assertEqual(target_expression_xml_str, new_rate['expression_mathml'])

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
def test_replace_rate_law_mathml(self):
amr = _d(self.sir_amr)
transition_id = 'inf'
Expand All @@ -435,7 +444,7 @@ def test_replace_rate_law_mathml(self):
self.assertEqual(sstr(target_expression_sympy), new_rate['expression'])
self.assertEqual(target_expression_xml_str, new_rate['expression_mathml'])

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
# Following 2 unit tests only test for replacing expressions in observables, not initials
def test_replace_observable_expression_sympy(self):
object_id = 'noninf'
Expand All @@ -449,7 +458,7 @@ def test_replace_observable_expression_sympy(self):
self.assertEqual(sstr(target_expression_sympy), new_obs['expression'])
self.assertEqual(target_expression_xml_str, new_obs['expression_mathml'])

@pytest.mark.sbmlmath
@SBMLMATH_REQUIRED
def test_replace_observable_expression_mathml(self):
object_id = 'noninf'
amr = _d(self.sir_amr)
Expand Down
Loading