Skip to content

Commit

Permalink
Fix simulation to allow a dict for dataset
Browse files Browse the repository at this point in the history
fixes 53

in the example from index.ipnyb we use dataset as a dict for household
cacluations.

In the code we were failing to correctly handle this case.

This happening, in part, because the type hint was wrong, but since most
of the type hints are wrong I'm fixing the bug first and will come back
to address the type hints.
  • Loading branch information
EC2 Default User committed Dec 5, 2024
1 parent b7cbaeb commit d96b2db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
fixed:
- Household simulation example broken due to a type error.
4 changes: 4 additions & 0 deletions policyengine/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def __init__(
self._initialise_simulations()

def _set_dataset(self, dataset: str):
if isinstance(dataset, dict):
self.data = dataset
return

if dataset in DATASETS[self.country]:
self.data = DATASETS[self.country][dataset]
elif dataset is None:
Expand Down

0 comments on commit d96b2db

Please sign in to comment.