Repository navigation
Expand file tree
/
Copy pathtest_conversion.py
More file actions
82 lines (66 loc) · 2.38 KB
/
Copy pathtest_conversion.py
File metadata and controls
82 lines (66 loc) · 2.38 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
74
75
76
77
78
79
80
81
82
import logging
import pandas as pd
import pytest
import petab.v1 as v1
import petab.v2 as v2
from petab.v2 import Problem
from petab.v2.petab1to2 import petab1to2, v1v2_observable_df
def test_v1v2_observable_df_noise_distribution():
"""Test that noiseDistribution is correctly merged with
observableTransformation."""
observable_df = pd.DataFrame(
data={
v1.C.OBSERVABLE_ID: ["obs1", "obs2"],
v1.C.OBSERVABLE_FORMULA: ["a", "b"],
v1.C.NOISE_FORMULA: ["1", "1"],
v1.C.OBSERVABLE_TRANSFORMATION: [v1.C.LIN, v1.C.LOG],
v1.C.NOISE_DISTRIBUTION: [v1.C.NORMAL, v1.C.NORMAL],
}
).set_index(v1.C.OBSERVABLE_ID)
new_df = v1v2_observable_df(observable_df)
assert list(new_df[v2.C.NOISE_DISTRIBUTION]) == [
v2.C.NORMAL,
v2.C.LOG_NORMAL,
]
def test_petab1to2_remote():
"""Test that we can upgrade a remote PEtab 1.0.0 problem."""
yaml_url = (
"https://cdn.jsdelivr.net/gh/PEtab-dev/petab_test_suite"
"@main/petabtests/cases/v1.0.0/sbml/0001/_0001.yaml"
)
problem = petab1to2(yaml_url)
assert isinstance(problem, Problem)
assert len(problem.measurements)
try:
import benchmark_models_petab
parametrize_or_skip = pytest.mark.parametrize(
"problem_id", benchmark_models_petab.MODELS
)
except ImportError:
parametrize_or_skip = pytest.mark.skip(
reason="benchmark_models_petab not installed"
)
@pytest.mark.filterwarnings(
"ignore:.*Using `log-normal` instead.*:UserWarning"
)
@pytest.mark.filterwarnings(
"ignore:.*Initialisation priors in parameter table are not supported.*:"
"UserWarning"
)
@pytest.mark.filterwarnings(
"ignore:.*Parameter scales are not supported in PEtab v2.*:UserWarning"
)
@parametrize_or_skip
def test_benchmark_collection(problem_id):
"""Test that we can upgrade all benchmark collection models."""
logging.basicConfig(level=logging.DEBUG)
if problem_id == "Froehlich_CellSystems2018":
# this is mostly about 6M sympifications in the condition table
pytest.skip("Too slow. Re-enable once we are faster.")
yaml_path = benchmark_models_petab.get_problem_yaml_path(problem_id)
try:
problem = petab1to2(yaml_path)
except NotImplementedError as e:
pytest.skip(str(e))
assert isinstance(problem, Problem)
assert len(problem.measurements)