diff --git a/documentation/python_interface.rst b/documentation/python_interface.rst index bdcb17e520..2f02648fcc 100644 --- a/documentation/python_interface.rst +++ b/documentation/python_interface.rst @@ -31,10 +31,25 @@ the semantic `SBML Test Suite `_ (`current status `_). -The following SBML test tags are supported +The following SBML test suite tags are currently supported (i.e., at least one test case with the respective test passes; `tag descriptions `_): +**Component tags:** + +* AssignmentRule +* Compartment +* CSymbolAvogadro +* CSymbolTime +* FunctionDefinition +* InitialAssignment +* Parameter +* RateRule +* Reaction +* Species + +**Test tags:** + * 0D-Compartment * Amount * AssignedConstantStoichiometry @@ -66,8 +81,6 @@ for details and progress): - Events (currently Matlab-only) (`#757 `_) - Algebraic rules (`#760 `_) -contributions are welcome. - However, the following features are unlikely to be supported: - any SBML extensions @@ -105,7 +118,7 @@ Importing plain ODEs The AMICI Python interface does not currently support direct import of ODEs. However, it is straightforward to encode them as RateRules in an SBML model. -The `yaml2sbml `_ package may come in +The `yaml2sbml `_ package may come in handy, as it facilitates generating SBML models from a YAML-based specification of an ODE model. Besides the SBML model it can also create `PEtab `_ files. @@ -140,21 +153,27 @@ OpenMP support for parallelized simulation for multiple experimental conditions AMICI can be built with OpenMP support, which allows to parallelize model simulations for multiple experimental conditions. -On Linux and OSX this is enabled by default. This can be verified using:: +On Linux and OSX this is enabled by default. This can be verified using: - import amici - amici.compiledWithOpenMP() +.. code-block:: python + + import amici + amici.compiledWithOpenMP() If not already enabled by default, you can enable OpenMP support by setting the environment variables ``AMICI_CXXFLAGS`` and ``AMICI_LDFLAGS`` to the correct OpenMP flags of your compiler and linker, respectively. This has to be done for both AMICI package installation *and* model compilation. When using -``gcc`` on Linux, this would be:: +``gcc`` on Linux, this would be: + +.. code-block:: bash + + # on your shell: + AMICI_CXXFLAGS=-fopenmp AMICI_LDFLAGS=-fopenmp pip3 install amici - # on your shell: - AMICI_CXXFLAGS=-fopenmp AMICI_LDFLAGS=-fopenmp pip3 install amici +.. code-block:: python - # in python, before model compilation: - import os - os.environ['AMICI_CXXFLAGS'] = '-fopenmp' - os.environ['AMICI_LDFLAGS'] = '-fopenmp' + # in python, before model compilation: + import os + os.environ['AMICI_CXXFLAGS'] = '-fopenmp' + os.environ['AMICI_LDFLAGS'] = '-fopenmp' diff --git a/tests/conftest.py b/tests/conftest.py index e6e1865354..89eb1342da 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,13 +75,21 @@ def pytest_sessionfinish(session, exitstatus): def write_passed_tags(passed_ids, out=sys.stdout): """Write tags of passed SBML semantic test cases""" - passed_tags = set() + passed_component_tags = set() + passed_test_tags = set() + from testSBMLSuite import get_tags_for_test for test_id in passed_ids: - passed_tags |= get_tags_for_test(test_id) - - out.write("At least one test with the following tags has passed:\n") - out.write(' ' + '\n '.join(passed_tags)) + cur_component_tags, cur_test_tags = get_tags_for_test(test_id) + passed_component_tags |= cur_component_tags + passed_test_tags |= cur_test_tags + + out.write("\nAt least one test with the following component tags has " + "passed:\n") + out.write(' ' + '\n '.join(sorted(passed_component_tags))) + out.write("\n\nAt least one test with the following test tags has " + "passed:\n") + out.write(' ' + '\n '.join(sorted(passed_test_tags))) def pytest_runtest_logreport(report: "TestReport") -> None: diff --git a/tests/testSBMLSuite.py b/tests/testSBMLSuite.py index 6555ea71c4..bc6189b092 100755 --- a/tests/testSBMLSuite.py +++ b/tests/testSBMLSuite.py @@ -19,6 +19,7 @@ import re import shutil import sys +from typing import Tuple, Set import amici import libsbml as sbml @@ -307,16 +308,28 @@ def format_test_id(test_id) -> str: return test_str -def get_tags_for_test(test_id): - """Get sbml test suite tags for the given test ID""" +def get_tags_for_test(test_id) -> Tuple[Set[str], Set[str]]: + """Get sbml test suite tags for the given test ID + + Returns: + Tuple of set of strings for componentTags and testTags + """ current_test_path = os.path.join(TEST_PATH, test_id) info_file = os.path.join(current_test_path, f'{test_id}-model.m') with open(info_file) as f: + component_tags = set() + test_tags = set() for line in f: if line.startswith('testTags:'): - res = set(re.split(r'[ ,:]', line[len('testTags:'):].strip())) - res.discard('') - return res - print(f"No testTags found for test case {test_id}.") - return set() + test_tags = set( + re.split(r'[ ,:]', line[len('testTags:'):].strip())) + test_tags.discard('') + if line.startswith('componentTags:'): + component_tags = set( + re.split(r'[ ,:]', line[len('componentTags:'):].strip())) + component_tags.discard('') + if test_tags and component_tags: + return component_tags, test_tags + print(f"No componentTags or testTags found for test case {test_id}.") + return component_tags, test_tags