From 7d44823502eae754b8ec1bd4971be96024d2b07e Mon Sep 17 00:00:00 2001 From: Marin Visscher Date: Tue, 17 Dec 2024 14:10:56 +0100 Subject: [PATCH] Parameter scenarios now sample on both parameter group and parameter name --- activity_browser/bwutils/utils.py | 4 ++-- activity_browser/ui/tables/models/scenarios.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/activity_browser/bwutils/utils.py b/activity_browser/bwutils/utils.py index 68d7aa5e6..d96169fee 100644 --- a/activity_browser/bwutils/utils.py +++ b/activity_browser/bwutils/utils.py @@ -163,8 +163,8 @@ def update(self, new_values: dict[str, float]) -> None: """Replace parameters in the list if their linked value is not NaN. """ - param_by_name = {p.name: p for p in self.data} - index_by_name = {p.name: i for i, p in enumerate(self.data)} + param_by_name = {(p.group, p.name): p for p in self.data} + index_by_name = {(p.group, p.name): i for i, p in enumerate(self.data)} for name, value in new_values.items(): if not np.isnan(value): diff --git a/activity_browser/ui/tables/models/scenarios.py b/activity_browser/ui/tables/models/scenarios.py index b68bac909..ff733d747 100644 --- a/activity_browser/ui/tables/models/scenarios.py +++ b/activity_browser/ui/tables/models/scenarios.py @@ -124,7 +124,11 @@ def iterate_scenarios(self) -> Iterable[Tuple[str, Iterable]]: TODO: Fix this so it returns the least amount of required information. """ + df = self._dataframe.reset_index() + df = df.set_index(["Group", "Name"]) + + return ( - (scenario, self._dataframe[scenario]) - for scenario in self._dataframe.columns[1:] + (scenario, df[scenario]) + for scenario in df.columns )