|
| 1 | +import subprocess |
1 | 2 | import tempfile |
2 | 3 | from pathlib import Path |
3 | 4 |
|
@@ -666,3 +667,43 @@ def test_generate_path(): |
666 | 667 | else: |
667 | 668 | assert gp(Path("foo"), "/bar") == "/bar/foo" |
668 | 669 | assert gp("/foo", "bar") == "/foo" |
| 670 | + |
| 671 | + |
| 672 | +def test_petablint_v2(tmpdir): |
| 673 | + """Test that petablint runs on a valid v2 problem without errors.""" |
| 674 | + problem = Problem() |
| 675 | + problem.model = SbmlModel.from_antimony(""" |
| 676 | + model conversion |
| 677 | + species A, B; |
| 678 | + A = 10; |
| 679 | + B = 0; |
| 680 | + k1 = 1; |
| 681 | + k2 = 0.5; |
| 682 | + R1: A -> B; k1 * A; |
| 683 | + R2: B -> A; k2 * B; |
| 684 | + end |
| 685 | + """) |
| 686 | + problem.add_observable("obs_A", "A", noise_formula="sd_A") |
| 687 | + problem.add_parameter( |
| 688 | + "k1", estimate=True, lb=1e-5, ub=1e5, nominal_value=1 |
| 689 | + ) |
| 690 | + problem.add_parameter( |
| 691 | + "k2", estimate=True, lb=1e-5, ub=1e5, nominal_value=0.5 |
| 692 | + ) |
| 693 | + problem.add_parameter( |
| 694 | + "sd_A", estimate=True, lb=0.01, ub=10, nominal_value=1 |
| 695 | + ) |
| 696 | + problem.add_measurement( |
| 697 | + "obs_A", time=10, measurement=2.5, experiment_id="" |
| 698 | + ) |
| 699 | + assert problem.validate() == [] |
| 700 | + |
| 701 | + problem.config = ProblemConfig(filepath="problem.yaml") |
| 702 | + problem.models[0].rel_path = "model.xml" |
| 703 | + problem.parameter_tables[0].rel_path = "parameters.tsv" |
| 704 | + problem.observable_tables[0].rel_path = "observables.tsv" |
| 705 | + problem.measurement_tables[0].rel_path = "measurements.tsv" |
| 706 | + problem.to_files(Path(tmpdir)) |
| 707 | + |
| 708 | + result = subprocess.run(["petablint", str(Path(tmpdir, "problem.yaml"))]) # noqa: S603,S607 |
| 709 | + assert result.returncode == 0 |
0 commit comments