8
8
import libsbml
9
9
from sbmlmath import sbml_math_to_sympy , set_math
10
10
11
- from .core import Change , Condition , Experiment , ExperimentPeriod
11
+ from .core import (
12
+ Change ,
13
+ Condition ,
14
+ ConditionTable ,
15
+ Experiment ,
16
+ ExperimentPeriod ,
17
+ )
12
18
from .models ._sbml_utils import add_sbml_parameter , check
13
19
from .models .sbml_model import SbmlModel
14
20
from .problem import Problem
@@ -176,7 +182,7 @@ def convert(self) -> Problem:
176
182
177
183
self ._add_preequilibration_indicator ()
178
184
179
- for experiment in self ._new_problem .experiment_table . experiments :
185
+ for experiment in self ._new_problem .experiments :
180
186
self ._convert_experiment (experiment )
181
187
182
188
self ._add_indicators_to_conditions ()
@@ -226,7 +232,7 @@ def _convert_experiment(self, experiment: Experiment) -> None:
226
232
self ._create_event_assignments_for_period (
227
233
ev ,
228
234
[
229
- self ._new_problem . condition_table [condition_id ]
235
+ self ._new_problem [condition_id ]
230
236
for condition_id in period .condition_ids
231
237
],
232
238
)
@@ -365,24 +371,18 @@ def _add_indicators_to_conditions(self) -> None:
365
371
problem = self ._new_problem
366
372
367
373
# create conditions for indicator parameters
368
- problem .condition_table .conditions .append (
369
- Condition (
370
- id = self .CONDITION_ID_PREEQ_ON ,
371
- changes = [
372
- Change (target_id = self ._preeq_indicator , target_value = 1 )
373
- ],
374
- )
374
+ problem += Condition (
375
+ id = self .CONDITION_ID_PREEQ_ON ,
376
+ changes = [Change (target_id = self ._preeq_indicator , target_value = 1 )],
375
377
)
376
- problem .condition_table .conditions .append (
377
- Condition (
378
- id = self .CONDITION_ID_PREEQ_OFF ,
379
- changes = [
380
- Change (target_id = self ._preeq_indicator , target_value = 0 )
381
- ],
382
- )
378
+
379
+ problem += Condition (
380
+ id = self .CONDITION_ID_PREEQ_OFF ,
381
+ changes = [Change (target_id = self ._preeq_indicator , target_value = 0 )],
383
382
)
383
+
384
384
# add conditions for the experiment indicators
385
- for experiment in problem .experiment_table . experiments :
385
+ for experiment in problem .experiments :
386
386
cond_id = self ._get_experiment_indicator_condition_id (
387
387
experiment .id
388
388
)
@@ -392,17 +392,19 @@ def _add_indicators_to_conditions(self) -> None:
392
392
target_value = 1 ,
393
393
)
394
394
]
395
- problem .condition_table .conditions .append (
396
- Condition (
397
- id = cond_id ,
398
- changes = changes ,
399
- )
395
+ problem += Condition (
396
+ id = cond_id ,
397
+ changes = changes ,
400
398
)
401
399
402
400
# All changes have been encoded in event assignments and can be
403
401
# removed. Only keep the conditions setting our indicators.
404
- problem .condition_table .conditions = [
405
- condition
406
- for condition in problem .condition_table .conditions
407
- if condition .id .startswith ("_petab" )
402
+ problem .condition_tables = [
403
+ ConditionTable (
404
+ conditions = [
405
+ condition
406
+ for condition in problem .conditions
407
+ if condition .id .startswith ("_petab" )
408
+ ]
409
+ )
408
410
]
0 commit comments