Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions petabtests/cases/v2.0.0/pysb/0010/0010.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# problem --------------------------------------------------------------------
problem = Problem()

problem.add_condition("preeq_c0", k1=0.3, B=0)
problem.add_condition("c0", k1=0.8, B=1)
problem.add_condition("preeq_c0", k1=0.3, B_c=0)
problem.add_condition("c0", k1=0.8, B_c=1)

problem.add_experiment("e0", TIME_PREEQUILIBRATION, "preeq_c0", 0, "c0")

Expand All @@ -35,8 +35,8 @@
problem.add_measurement("obs_a", experiment_id="e0", time=10, measurement=0.1)

problem.add_parameter("k2", lb=0, ub=10, nominal_value=0.6, estimate=True)
problem.add_mapping("A", "A_() ** compartment")
problem.add_mapping("B", "B_() ** compartment")
problem.add_mapping("A_c", "A_() ** compartment")
problem.add_mapping("B_c", "B_() ** compartment")


# solutions ------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0010/_conditions.tsv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
conditionId targetId targetValue
preeq_c0 k1 0.3
preeq_c0 B 0.0
preeq_c0 B_c 0.0
c0 k1 0.8
c0 B 1.0
c0 B_c 1.0
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0010/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
petabEntityId modelEntityId name
A A_() ** compartment
B B_() ** compartment
A_c A_() ** compartment
B_c B_() ** compartment
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0011/0011.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# problem --------------------------------------------------------------------
problem = Problem()

problem.add_condition("c0", B=2)
problem.add_condition("c0", B_c=2)

problem.add_experiment("e0", 0, "c0")

Expand All @@ -33,8 +33,8 @@
problem.add_parameter("k1", lb=0, ub=10, nominal_value=0.8, estimate=True)
problem.add_parameter("k2", lb=0, ub=10, nominal_value=0.6, estimate=True)

problem.add_mapping("A", "A_() ** compartment")
problem.add_mapping("B", "B_() ** compartment")
problem.add_mapping("A_c", "A_() ** compartment")
problem.add_mapping("B_c", "B_() ** compartment")

# solutions ------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion petabtests/cases/v2.0.0/pysb/0011/_conditions.tsv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
conditionId targetId targetValue
c0 B 2.0
c0 B_c 2.0
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0011/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
petabEntityId modelEntityId name
A A_() ** compartment
B B_() ** compartment
A_c A_() ** compartment
B_c B_() ** compartment
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0013/0013.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# problem --------------------------------------------------------------------
problem = Problem()

problem.add_condition("c0", B="par")
problem.add_condition("c0", B_c="par")
problem.add_experiment("e0", 0, "c0")
problem.add_observable("obs_a", "A", noise_formula=0.5)

Expand All @@ -30,8 +30,8 @@
problem.add_parameter("k2", lb=0, ub=10, nominal_value=0.6, estimate=True)
problem.add_parameter("par", lb=0, ub=10, nominal_value=7, estimate=True)

problem.add_mapping("A", "A_() ** compartment")
problem.add_mapping("B", "B_() ** compartment")
problem.add_mapping("A_c", "A_() ** compartment")
problem.add_mapping("B_c", "B_() ** compartment")

# solutions ------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion petabtests/cases/v2.0.0/pysb/0013/_conditions.tsv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
conditionId targetId targetValue
c0 B par
c0 B_c par
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0013/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
petabEntityId modelEntityId name
A A_() ** compartment
B B_() ** compartment
A_c A_() ** compartment
B_c B_() ** compartment
8 changes: 4 additions & 4 deletions petabtests/cases/v2.0.0/pysb/0017/0017.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@

# problem --------------------------------------------------------------------
problem = Problem()
problem.add_condition("preeq_c0", k1=0.3, B=2.0, A=0)
problem.add_condition("c0", k1=0.8, A=1)
problem.add_condition("preeq_c0", k1=0.3, B_c=2.0, A_c=0)
problem.add_condition("c0", k1=0.8, A_c=1)
problem.add_experiment("e0", TIME_PREEQUILIBRATION, "preeq_c0", 0, "c0")
problem.add_observable("obs_a", "A", noise_formula=0.5)
problem.add_measurement("obs_a", experiment_id="e0", time=1, measurement=0.7)
problem.add_measurement("obs_a", experiment_id="e0", time=10, measurement=0.1)
problem.add_parameter(
"k2", lb=0, ub=10, nominal_value=0.6, scale=LIN, estimate=True
)
problem.add_mapping("A", "A_() ** compartment")
problem.add_mapping("B", "B_() ** compartment")
problem.add_mapping("A_c", "A_() ** compartment")
problem.add_mapping("B_c", "B_() ** compartment")

# solutions ------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions petabtests/cases/v2.0.0/pysb/0017/_conditions.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
conditionId targetId targetValue
preeq_c0 k1 0.3
preeq_c0 B 2.0
preeq_c0 A 0.0
preeq_c0 B_c 2.0
preeq_c0 A_c 0.0
c0 k1 0.8
c0 A 1.0
c0 A_c 1.0
4 changes: 2 additions & 2 deletions petabtests/cases/v2.0.0/pysb/0017/_mapping.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
petabEntityId modelEntityId name
A A_() ** compartment
B B_() ** compartment
A_c A_() ** compartment
B_c B_() ** compartment
38 changes: 38 additions & 0 deletions test/test_general.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import petabtests
import os
import pytest


def test_cases_dir_exists():
Expand All @@ -14,3 +15,40 @@ def test_cases_dir_exists():
assert os.path.isdir(
petabtests.get_cases_dir(format_="pysb", version="v2.0.0")
)


@pytest.mark.parametrize(
"format_,version",
[
("sbml", "v2.0.0"),
("pysb", "v2.0.0"),
],
)
def test_lint_all_v2_cases(format_, version):
"""Regression test: all v2 test cases must pass PEtab linting."""
from petab.v2.lint import lint_problem

cases_dir = petabtests.get_cases_dir(format_=format_, version=version)
cases = sorted(
f.name
for f in os.scandir(cases_dir)
if f.is_dir() and f.name.isdigit()
)
assert cases, f"No cases found in {cases_dir}"

failures = {}
for case_id in cases:
yaml_path = cases_dir / case_id / f"_{case_id}.yaml"
if not yaml_path.exists():
continue
results = lint_problem(yaml_path)
if results:
failures[case_id] = [str(r) for r in results]

assert not failures, (
"Linting failed for the following test cases:\n"
+ "\n".join(
f" {case_id}: {'; '.join(errs)}"
for case_id, errs in sorted(failures.items())
)
)