From c112f57bb0b918a9ef148bf5c297c576fd700688 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 16 May 2025 09:49:13 +0100 Subject: [PATCH 1/2] Handle bad `enhanced_cps` specification in Simulation initialisation Fixes #134 --- policyengine/simulation.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/policyengine/simulation.py b/policyengine/simulation.py index ecb794fc..0ed1ee89 100644 --- a/policyengine/simulation.py +++ b/policyengine/simulation.py @@ -43,7 +43,7 @@ class SimulationOptions(BaseModel): scope: ScopeType = Field(..., description="The scope of the simulation.") data: DataType = Field(None, description="The data to simulate.") time_period: TimePeriodType = Field( - 2025, description="The time period to simulate.", ge=2024, le=2035 + 2025, description="The time period to simulate.", ge=2023, le=2040 ) reform: ReformType = Field(None, description="The reform to simulate.") baseline: ReformType = Field(None, description="The baseline to simulate.") @@ -172,6 +172,14 @@ def _initialise_simulations(self): else: self.is_comparison = False + def _handle_legacy_ecps_region_specification( + self, + ): + options = self.options + if "enhanced_us" in options.region: + options.region = None + options.data = "gs://policyengine-us-data/enhanced_cps_2024.h5" + def _initialise_simulation( self, country: CountryType, @@ -194,6 +202,8 @@ def _initialise_simulation( }, }[country][macro] + self._handle_legacy_ecps_region_specification() + if isinstance(reform, ParametricReform): reform = reform.model_dump() From 76eff3d6eb2af9364c78d51a7645065f9c6de70c Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Fri, 16 May 2025 11:58:22 +0100 Subject: [PATCH 2/2] Fix bug --- policyengine/simulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policyengine/simulation.py b/policyengine/simulation.py index 0ed1ee89..f307293d 100644 --- a/policyengine/simulation.py +++ b/policyengine/simulation.py @@ -176,7 +176,7 @@ def _handle_legacy_ecps_region_specification( self, ): options = self.options - if "enhanced_us" in options.region: + if options.region is not None and "enhanced_us" in options.region: options.region = None options.data = "gs://policyengine-us-data/enhanced_cps_2024.h5"