forked from PEtab-dev/libpetab-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_deprecated.py
More file actions
73 lines (61 loc) · 2.2 KB
/
test_deprecated.py
File metadata and controls
73 lines (61 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Check that deprecated functionality raises but still works."""
import tempfile
from pathlib import Path
import pytest
import petab
from .test_petab import petab_problem # noqa: F401
from .test_sbml import check_model, create_test_data
def test_problem_with_sbml_model():
"""Test that a problem can be correctly created from sbml model."""
# retrieve test data
(
model,
condition_df,
observable_df,
measurement_df,
parameter_df,
) = create_test_data()
with pytest.deprecated_call():
petab_problem = petab.Problem( # noqa: F811
model=model,
condition_df=condition_df,
measurement_df=measurement_df,
parameter_df=parameter_df,
)
with pytest.warns(
UserWarning,
match="An SBML rule was removed to set the component "
"species_2 to a constant value.",
):
_, condition_model = petab.get_model_for_condition(
petab_problem, "condition_1"
)
check_model(condition_model)
def test_to_files_with_sbml_model(petab_problem): # noqa: F811
"""Test problem.to_files."""
with tempfile.TemporaryDirectory() as outdir:
# create target files
sbml_file = Path(outdir, "model.xml")
condition_file = Path(outdir, "conditions.tsv")
measurement_file = Path(outdir, "measurements.tsv")
parameter_file = Path(outdir, "parameters.tsv")
observable_file = Path(outdir, "observables.tsv")
# write contents to files
with pytest.deprecated_call():
petab_problem.to_files(
sbml_file=sbml_file,
condition_file=condition_file,
measurement_file=measurement_file,
parameter_file=parameter_file,
visualization_file=None,
observable_file=observable_file,
yaml_file=None,
)
# exemplarily load some
parameter_df = petab.get_parameter_df(parameter_file)
same_nans = parameter_df.isna() == petab_problem.parameter_df.isna()
assert (
((parameter_df == petab_problem.parameter_df) | same_nans)
.all()
.all()
)