Skip to content

Commit 51db0dd

Browse files
m-philippsdilpath
andauthored
remove visualization df if invalid (#316)
* Remove the visualization table if it has observables that are not in the flattened observable table. Co-authored-by: Dilan Pathirana <[email protected]>
1 parent 09661eb commit 51db0dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

petab/v1/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ def flatten_timepoint_specific_output_overrides(
299299
petab_problem.observable_df.index.name = OBSERVABLE_ID
300300
petab_problem.measurement_df = pd.concat(new_measurement_dfs)
301301

302+
# remove visualization df if it uses observables that are not in the
303+
# flattened PEtab problem
304+
if petab_problem.visualization_df is not None:
305+
assert petab_problem.observable_df.index.name == OBSERVABLE_ID
306+
if not all(
307+
petab_problem.observable_df.index.isin(
308+
petab_problem.visualization_df[Y_VALUES]
309+
)
310+
):
311+
petab_problem.visualization_df = None
312+
logger.warning(
313+
"Removing visualization table from flattened PEtab problem."
314+
)
315+
302316

303317
def unflatten_simulation_df(
304318
simulation_df: pd.DataFrame,

0 commit comments

Comments
 (0)