|
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, |
@@ -255,18 +255,36 @@ def test_parameter(): |
255 | 255 |
|
256 | 256 | def test_experiment(): |
257 | 257 | Experiment(id="experiment1") |
258 | | - Experiment( |
259 | | - id="experiment1", periods=[ExperimentPeriod(time=1, condition_id="c1")] |
260 | | - ) |
261 | 258 |
|
| 259 | + # extra fields allowed |
262 | 260 | assert Experiment(id="experiment1", non_petab=1).non_petab == 1 |
263 | 261 |
|
| 262 | + # ID required |
264 | 263 | with pytest.raises(ValidationError, match="Field required"): |
265 | 264 | Experiment() |
266 | 265 |
|
| 266 | + # valid ID required |
267 | 267 | with pytest.raises(ValidationError, match="Invalid ID"): |
268 | 268 | Experiment(id="experiment 1") |
269 | 269 |
|
| 270 | + periods = [ |
| 271 | + ExperimentPeriod(time=C.TIME_PREEQUILIBRATION, condition_ids=["c1"]), |
| 272 | + ExperimentPeriod(time=-1, condition_id="c1"), |
| 273 | + ExperimentPeriod(time=1, condition_id="c1"), |
| 274 | + ] |
| 275 | + e = Experiment(id="experiment1", periods=list(reversed(periods))) |
| 276 | + |
| 277 | + assert e.has_preequilibration is True |
| 278 | + |
| 279 | + assert e.sorted_periods == periods |
| 280 | + assert e.periods != periods |
| 281 | + |
| 282 | + e.sort_periods() |
| 283 | + assert e.periods == periods |
| 284 | + |
| 285 | + e.periods.pop(0) |
| 286 | + assert e.has_preequilibration is False |
| 287 | + |
270 | 288 |
|
271 | 289 | def test_condition_table(): |
272 | 290 | assert ConditionTable().free_symbols == set() |
|
0 commit comments