Skip to content
Open
Show file tree
Hide file tree
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
24 changes: 16 additions & 8 deletions src/python/benchmark_models_petab/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,23 @@ def make_sbml4humans_urls(
]


def _fillna_str(df: pd.DataFrame, column: str, value: str) -> pd.DataFrame:
"""Fill missing values in a string column.

Columns without any values are read as float, which can't be filled with
strings.
"""
return df.astype({column: "string"}).fillna({column: value})


def get_noise_distributions(observable_df):
if petab.NOISE_DISTRIBUTION in observable_df.columns:
observable_df = observable_df.fillna(
value={petab.NOISE_DISTRIBUTION: petab.NORMAL}
observable_df = _fillna_str(
observable_df, petab.NOISE_DISTRIBUTION, petab.NORMAL
)
if petab.OBSERVABLE_TRANSFORMATION in observable_df.columns:
observable_df = observable_df.fillna(
value={petab.OBSERVABLE_TRANSFORMATION: petab.LIN}
observable_df = _fillna_str(
observable_df, petab.OBSERVABLE_TRANSFORMATION, petab.LIN
)
noise_distrs = [
tuple(e.values)
Expand All @@ -199,8 +208,8 @@ def get_noise_distributions(observable_df):

else:
if petab.OBSERVABLE_TRANSFORMATION in observable_df.columns:
observable_df = observable_df.fillna(
value={petab.OBSERVABLE_TRANSFORMATION: petab.LIN}
observable_df = _fillna_str(
observable_df, petab.OBSERVABLE_TRANSFORMATION, petab.LIN
)
noise_distrs = [
(e, petab.NORMAL)
Expand Down Expand Up @@ -337,8 +346,7 @@ def get_overview_df() -> pd.DataFrame:
summary = get_summary(petab_problem, petab_problem_id)
data.append(summary)
df = pd.DataFrame(data)
df.set_index([index_column], inplace=True)
return df
return df.set_index([index_column])


start_overview_table = "\n<!-- START OVERVIEW TABLE -->\n"
Expand Down
3 changes: 1 addition & 2 deletions src/python/benchmark_models_petab/overview_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,4 @@ def get_overview_df() -> pd.DataFrame:
for petab_problem_id in v2.MODELS
]
df = pd.DataFrame(data, columns=list(columns))
df.set_index([index_column], inplace=True)
return df
return df.set_index([index_column])
Loading