Skip to content

Commit 9a7bfc0

Browse files
authored
Merge pull request #2953 from PolicyEngine/feature/state-specific-datasets
Explicitly use default datasets for US state-level simulations
2 parents eb519ec + 8532c6f commit 9a7bfc0

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: minor
2+
changes:
3+
changed:
4+
- Set dataset to None for US state-level simulations in economy service

policyengine_api/services/economy_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ def _setup_data(
484484
if dataset == "enhanced_cps":
485485
return "gs://policyengine-us-data/enhanced_cps_2024.h5"
486486

487-
# US state-level simulations must reference pooled CPS dataset
488-
if country_id == "us" and region != "us":
487+
# NYC simulations must reference pooled CPS dataset
488+
if region == "nyc":
489489
return "gs://policyengine-us-data/pooled_3_year_cps_2023.h5"
490490

491-
# All others receive no sim API 'data' arg
491+
# All others (including US state-level simulations) receive no sim API 'data' arg
492492
return None
493493

494494
# Note: The following methods that interface with the ReformImpactsService

tests/unit/services/test_economy_service.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,7 @@ def test__given_us_state__returns_correct_sim_options(self):
595595
)
596596
assert sim_options["time_period"] == time_period
597597
assert sim_options["region"] == "state/ca"
598-
assert (
599-
sim_options["data"]
600-
== "gs://policyengine-us-data/pooled_3_year_cps_2023.h5"
601-
)
598+
assert sim_options["data"] is None
602599

603600
def test__given_enhanced_cps_state__returns_correct_sim_options(self):
604601
# Test with enhanced_cps dataset
@@ -720,12 +717,25 @@ def test__given_enhanced_cps_dataset__returns_correct_gcp_path(self):
720717
# Assert the expected value
721718
assert result == "gs://policyengine-us-data/enhanced_cps_2024.h5"
722719

723-
def test__given_us_state_dataset__returns_correct_gcp_path(self):
724-
# Test with US state dataset
720+
def test__given_us_state_dataset__returns_none(self):
721+
# Test with US state dataset - should return None
725722
dataset = "us_state"
726723
country_id = "us"
727724
region = "ca"
728725

726+
# Create an instance of the class
727+
service = EconomyService()
728+
# Call the method
729+
result = service._setup_data(dataset, country_id, region)
730+
# Assert the expected value
731+
assert result is None
732+
733+
def test__given_nyc_region__returns_pooled_cps(self):
734+
# Test with NYC region - should return pooled CPS dataset
735+
dataset = None
736+
country_id = "us"
737+
region = "nyc"
738+
729739
# Create an instance of the class
730740
service = EconomyService()
731741
# Call the method

0 commit comments

Comments
 (0)