diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29b..a07555d0 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Fixed a bug in Core monthlyisation. diff --git a/policyengine_core/data/dataset.py b/policyengine_core/data/dataset.py index 05a2cba0..3235c956 100644 --- a/policyengine_core/data/dataset.py +++ b/policyengine_core/data/dataset.py @@ -33,7 +33,7 @@ class Dataset: _table_cache: Dict[str, pd.DataFrame] = None - def __init__(self, regenerate: bool = False): + def __init__(self, require: bool = False): # Setup dataset if self.file_path is None: raise ValueError( @@ -66,9 +66,7 @@ def __init__(self, regenerate: bool = False): "You tried to instantiate a Dataset object, but no time_period has been provided." ) - if regenerate: - self.generate() - elif not self.exists: + if not self.exists and require: if self.url is not None: self.download() else: diff --git a/policyengine_core/simulations/simulation.py b/policyengine_core/simulations/simulation.py index 40ec8b30..d68ecd28 100644 --- a/policyengine_core/simulations/simulation.py +++ b/policyengine_core/simulations/simulation.py @@ -153,7 +153,7 @@ def __init__( ) dataset = datasets_by_name[dataset] if isinstance(dataset, type): - self.dataset: Dataset = dataset() + self.dataset: Dataset = dataset(require=True) else: self.dataset = dataset self.build_from_dataset() @@ -227,6 +227,7 @@ def build_from_dataset(self) -> None: builder = SimulationBuilder() builder.populations = self.populations + try: data = self.dataset.load() except FileNotFoundError as e: @@ -576,6 +577,7 @@ def _calculate( start_instants = [ str(known_period.start) for known_period in known_periods + if known_period.unit == variable.definition_period ] latest_known_period = known_periods[ np.argmax(start_instants)