Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions petab/v1/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ def calculate_residuals_for_table(
)
residual_df[RESIDUAL] = residual_df[RESIDUAL].astype("float64")
# matching columns
compared_cols = set(MEASUREMENT_DF_COLS)
compared_cols -= {MEASUREMENT}
compared_cols &= set(measurement_df.columns)
compared_cols &= set(simulation_df.columns)
compared_cols = set(measurement_df.columns) & set(simulation_df.columns)

# compute noise formulas for observables
noise_formulas = get_symbolic_noise_formulas(observable_df)
Expand All @@ -127,6 +124,16 @@ def calculate_residuals_for_table(
raise ValueError(
f"Could not find simulation for measurement {row}."
)
# if we have multiple matches, check that the rows are all identical
elif (
mask.sum() > 1
and simulation_df.loc[mask].drop_duplicates().shape[0] > 1
):
raise ValueError(
f"Multiple different simulations found for measurement "
f"{row}:\n{simulation_df.loc[mask]}"
)

simulation = simulation_df.loc[mask][SIMULATION].iloc[0]
if scale:
# apply scaling
Expand Down Expand Up @@ -343,10 +350,7 @@ def calculate_llh_for_table(
llhs = []

# matching columns
compared_cols = set(MEASUREMENT_DF_COLS)
compared_cols -= {MEASUREMENT}
compared_cols &= set(measurement_df.columns)
compared_cols &= set(simulation_df.columns)
compared_cols = set(measurement_df.columns) & set(simulation_df.columns)

# compute noise formulas for observables
noise_formulas = get_symbolic_noise_formulas(observable_df)
Expand Down
Loading