88import libsbml
99from sbmlmath import sbml_math_to_sympy , set_math
1010
11- from .core import Change , Condition , Experiment , ExperimentPeriod
11+ from .core import (
12+ Change ,
13+ Condition ,
14+ ConditionTable ,
15+ Experiment ,
16+ ExperimentPeriod ,
17+ )
1218from .models ._sbml_utils import add_sbml_parameter , check
1319from .models .sbml_model import SbmlModel
1420from .problem import Problem
@@ -176,7 +182,7 @@ def convert(self) -> Problem:
176182
177183 self ._add_preequilibration_indicator ()
178184
179- for experiment in self ._new_problem .experiment_table . experiments :
185+ for experiment in self ._new_problem .experiments :
180186 self ._convert_experiment (experiment )
181187
182188 self ._add_indicators_to_conditions ()
@@ -226,7 +232,7 @@ def _convert_experiment(self, experiment: Experiment) -> None:
226232 self ._create_event_assignments_for_period (
227233 ev ,
228234 [
229- self ._new_problem . condition_table [condition_id ]
235+ self ._new_problem [condition_id ]
230236 for condition_id in period .condition_ids
231237 ],
232238 )
@@ -365,24 +371,18 @@ def _add_indicators_to_conditions(self) -> None:
365371 problem = self ._new_problem
366372
367373 # 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 )],
375377 )
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 )],
383382 )
383+
384384 # add conditions for the experiment indicators
385- for experiment in problem .experiment_table . experiments :
385+ for experiment in problem .experiments :
386386 cond_id = self ._get_experiment_indicator_condition_id (
387387 experiment .id
388388 )
@@ -392,17 +392,19 @@ def _add_indicators_to_conditions(self) -> None:
392392 target_value = 1 ,
393393 )
394394 ]
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 ,
400398 )
401399
402400 # All changes have been encoded in event assignments and can be
403401 # 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+ )
408410 ]
0 commit comments