Skip to content

Commit

Permalink
Update wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
albrja committed Nov 7, 2024
1 parent e27aee7 commit 793ac11
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vivarium/framework/results/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,21 @@ def __init__(
to_observe: Callable[[Event], bool] = lambda event: True,
):
def _wrap_results_gatherer(
df: pd.DataFrame, _: tuple[str, ...] | None
df: pd.DataFrame | DataFrameGroupBy[str], _: tuple[str, ...] | None
) -> pd.DataFrame:
if isinstance(df, DataFrameGroupBy):
raise TypeError(
"Must provide a dataframe to an UnstratifiedObservation. "
f"Provided DataFrameGroupBy instead."
)
return results_gatherer(df)

super().__init__(
name=name,
pop_filter=pop_filter,
when=when,
results_initializer=self.create_empty_df,
results_gatherer=_wrap_results_gatherer, # type: ignore [arg-type]
results_gatherer=_wrap_results_gatherer,
results_updater=results_updater,
results_formatter=results_formatter,
stratifications=None,
Expand Down

0 comments on commit 793ac11

Please sign in to comment.