@@ -420,10 +420,9 @@ def condition_df(self, value: pd.DataFrame):
420420 @property
421421 def experiment_df (self ) -> pd .DataFrame | None :
422422 """Experiment table as DataFrame."""
423- experiments = self .experiments
424423 return (
425424 core .ExperimentTable (experiments = experiments ).to_df ()
426- if experiments
425+ if ( experiments := self . experiments )
427426 else None
428427 )
429428
@@ -933,7 +932,9 @@ def add_condition(
933932
934933 Arguments:
935934 id_: The condition id
936- name: The condition name
935+ name: The condition name. If given, this will be added to the
936+ last mapping table. If no mapping table exists,
937+ a new mapping table will be created.
937938 kwargs: Entities to be added to the condition table in the form
938939 `target_id=target_value`.
939940 """
@@ -950,14 +951,7 @@ def add_condition(
950951 core .Condition (id = id_ , changes = changes )
951952 )
952953 if name is not None :
953- if not self .mapping_tables :
954- self .mapping_tables .append (core .MappingTable (mappings = []))
955- self .mapping_tables [- 1 ].mappings .append (
956- core .Mapping (
957- petab_id = id_ ,
958- name = name ,
959- )
960- )
954+ self .add_mapping (petab_id = id_ , name = name )
961955
962956 def add_observable (
963957 self ,
@@ -1110,7 +1104,9 @@ def add_measurement(
11101104 )
11111105 )
11121106
1113- def add_mapping (self , petab_id : str , model_id : str , name : str = None ):
1107+ def add_mapping (
1108+ self , petab_id : str , model_id : str = None , name : str = None
1109+ ):
11141110 """Add a mapping table entry to the problem.
11151111
11161112 If there are more than one mapping tables, the mapping
@@ -1119,6 +1115,7 @@ def add_mapping(self, petab_id: str, model_id: str, name: str = None):
11191115 Arguments:
11201116 petab_id: The new PEtab-compatible ID mapping to `model_id`
11211117 model_id: The ID of some entity in the model
1118+ name: A name (any string) for the entity referenced by `petab_id`.
11221119 """
11231120 if not self .mapping_tables :
11241121 self .mapping_tables .append (core .MappingTable (mappings = []))
@@ -1262,7 +1259,6 @@ def model_dump(self, **kwargs) -> dict[str, Any]:
12621259 if table_list
12631260 else []
12641261 )
1265-
12661262 return res
12671263
12681264
0 commit comments