Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
* The 'preprocessed task' is no longer helping in the test where it was being used; get rid of it.
* Now that parameters controlled by rules are valid, don't test to make sure it's invalid; move it to the 'make sure it's valid' section.
  • Loading branch information
luciansmith committed Oct 17, 2024
1 parent be8bf21 commit 3598c44
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions tests/test_core_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ def test_exec_sed_task_with_changes(self):
task=task,
))

preprocessed_task = core.preprocess_sed_task(task, variables)

task.model.changes = []
results, _ = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
results, _ = core.exec_sed_task(task, variables)

task.simulation.output_end_time /= 2
task.simulation.number_of_points = int(task.simulation.number_of_points / 2)
results2, _ = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
results2, _ = core.exec_sed_task(task, variables)
for specie in species:
numpy.testing.assert_allclose(results2[specie], results[specie][0:task.simulation.number_of_points + 1])

Expand All @@ -191,7 +189,7 @@ def test_exec_sed_task_with_changes(self):
target_namespaces=self.NAMESPACES,
new_value=results2[specie][-1],
))
results3, _ = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
results3, _ = core.exec_sed_task(task, variables)
for specie in species:
numpy.testing.assert_allclose(results3[specie], results[specie][task.simulation.number_of_points:], rtol=1e-4)

Expand All @@ -201,10 +199,16 @@ def test_exec_sed_task_with_changes(self):
target_namespaces=self.NAMESPACES,
new_value=str(results2[specie][-1]),
))
results3, _ = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
results3, _ = core.exec_sed_task(task, variables)
for specie in species:
numpy.testing.assert_allclose(results3[specie], results[specie][task.simulation.number_of_points:], rtol=1e-4)

task2 = copy.deepcopy(task)
task2.model.source = os.path.join(os.path.dirname(__file__), 'fixtures', 'biomd0000000678.xml')
variables2 = copy.deepcopy(variables[1:2])
variables2[0].target = "/sbml:sbml/sbml:model/sbml:listOfParameters/sbml:parameter[@id='dNFAT']"
core.exec_sed_task(task2, variables2)

def test_exec_sed_task_error_handling(self):
with mock.patch.dict('os.environ', {'ALGORITHM_SUBSTITUTION_POLICY': 'NONE'}):
task = sedml_data_model.Task(
Expand Down Expand Up @@ -287,14 +291,6 @@ def test_exec_sed_task_error_handling(self):
core.exec_sed_task(task, variables)
variables[0].symbol = sedml_data_model.Symbol.time

task2 = copy.deepcopy(task)
task2.model.source = os.path.join(os.path.dirname(__file__), 'fixtures', 'biomd0000000678.xml')
variables2 = copy.deepcopy(variables[1:2])
variables2[0].target = "/sbml:sbml/sbml:model/sbml:listOfParameters/sbml:parameter[@id='dNFAT']"
with self.assertRaisesRegex(ValueError, 'targets cannot not be recorded'):
core.exec_sed_task(task2, variables2)
variables[1].target = "/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='AL']"

# algorithm substition
task = sedml_data_model.Task(
model=sedml_data_model.Model(
Expand Down

0 comments on commit 3598c44

Please sign in to comment.