|
10 | 10 | from sympy.abc import x, y
|
11 | 11 |
|
12 | 12 | import petab.v2 as petab
|
13 |
| -from petab.v2 import Problem |
| 13 | +from petab.v2 import C, Problem |
14 | 14 | from petab.v2.C import (
|
15 | 15 | CONDITION_ID,
|
16 | 16 | ESTIMATE,
|
@@ -256,18 +256,36 @@ def test_parameter():
|
256 | 256 |
|
257 | 257 | def test_experiment():
|
258 | 258 | Experiment(id="experiment1")
|
259 |
| - Experiment( |
260 |
| - id="experiment1", periods=[ExperimentPeriod(time=1, condition_id="c1")] |
261 |
| - ) |
262 | 259 |
|
| 260 | + # extra fields allowed |
263 | 261 | assert Experiment(id="experiment1", non_petab=1).non_petab == 1
|
264 | 262 |
|
| 263 | + # ID required |
265 | 264 | with pytest.raises(ValidationError, match="Field required"):
|
266 | 265 | Experiment()
|
267 | 266 |
|
| 267 | + # valid ID required |
268 | 268 | with pytest.raises(ValidationError, match="Invalid ID"):
|
269 | 269 | Experiment(id="experiment 1")
|
270 | 270 |
|
| 271 | + periods = [ |
| 272 | + ExperimentPeriod(time=C.TIME_PREEQUILIBRATION, condition_ids=["c1"]), |
| 273 | + ExperimentPeriod(time=-1, condition_id="c1"), |
| 274 | + ExperimentPeriod(time=1, condition_id="c1"), |
| 275 | + ] |
| 276 | + e = Experiment(id="experiment1", periods=list(reversed(periods))) |
| 277 | + |
| 278 | + assert e.has_preequilibration is True |
| 279 | + |
| 280 | + assert e.sorted_periods == periods |
| 281 | + assert e.periods != periods |
| 282 | + |
| 283 | + e.sort_periods() |
| 284 | + assert e.periods == periods |
| 285 | + |
| 286 | + e.periods.pop(0) |
| 287 | + assert e.has_preequilibration is False |
| 288 | + |
271 | 289 |
|
272 | 290 | def test_condition_table():
|
273 | 291 | assert ConditionTable().free_symbols == set()
|
|
0 commit comments