Skip to content

Commit 18d635a

Browse files
baogorekclaude
andcommitted
Format test files with black
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5b7fbb8 commit 18d635a

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

policyengine_us_data/tests/test_local_area_calibration/create_test_fixture.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ def create_test_fixture():
2323
np.random.seed(SEED)
2424

2525
# Create household structure: 50 households with 1-4 persons each
26-
persons_per_hh = np.random.choice([1, 2, 3, 4], size=N_HOUSEHOLDS, p=[0.3, 0.4, 0.2, 0.1])
26+
persons_per_hh = np.random.choice(
27+
[1, 2, 3, 4], size=N_HOUSEHOLDS, p=[0.3, 0.4, 0.2, 0.1]
28+
)
2729
n_persons = persons_per_hh.sum()
2830

2931
# Household-level arrays
3032
household_ids = np.arange(N_HOUSEHOLDS, dtype=np.int32)
31-
household_weights = np.random.uniform(500, 3000, N_HOUSEHOLDS).astype(np.float32)
33+
household_weights = np.random.uniform(500, 3000, N_HOUSEHOLDS).astype(
34+
np.float32
35+
)
3236

3337
# Assign households to states (use NC=37 and AK=2 for testing)
3438
# 40 households in NC, 10 in AK
@@ -53,7 +57,7 @@ def create_test_fixture():
5357
ages = np.random.choice(
5458
[5, 15, 25, 35, 45, 55, 65, 75],
5559
size=n_persons,
56-
p=[0.1, 0.1, 0.15, 0.2, 0.15, 0.15, 0.1, 0.05]
60+
p=[0.1, 0.1, 0.15, 0.2, 0.15, 0.15, 0.1, 0.05],
5761
).astype(np.int32)
5862

5963
# Employment income: working-age adults have income
@@ -98,14 +102,18 @@ def create_test_fixture():
98102
f["household_id"].create_dataset(TIME_PERIOD, data=household_ids)
99103

100104
f.create_group("household_weight")
101-
f["household_weight"].create_dataset(TIME_PERIOD, data=household_weights)
105+
f["household_weight"].create_dataset(
106+
TIME_PERIOD, data=household_weights
107+
)
102108

103109
# Person variables
104110
f.create_group("person_id")
105111
f["person_id"].create_dataset(TIME_PERIOD, data=person_ids)
106112

107113
f.create_group("person_household_id")
108-
f["person_household_id"].create_dataset(TIME_PERIOD, data=person_household_ids)
114+
f["person_household_id"].create_dataset(
115+
TIME_PERIOD, data=person_household_ids
116+
)
109117

110118
f.create_group("person_weight")
111119
f["person_weight"].create_dataset(TIME_PERIOD, data=person_weights)
@@ -114,14 +122,18 @@ def create_test_fixture():
114122
f["age"].create_dataset(TIME_PERIOD, data=ages)
115123

116124
f.create_group("employment_income")
117-
f["employment_income"].create_dataset(TIME_PERIOD, data=employment_income)
125+
f["employment_income"].create_dataset(
126+
TIME_PERIOD, data=employment_income
127+
)
118128

119129
# Tax unit
120130
f.create_group("tax_unit_id")
121131
f["tax_unit_id"].create_dataset(TIME_PERIOD, data=tax_unit_ids)
122132

123133
f.create_group("person_tax_unit_id")
124-
f["person_tax_unit_id"].create_dataset(TIME_PERIOD, data=person_tax_unit_ids)
134+
f["person_tax_unit_id"].create_dataset(
135+
TIME_PERIOD, data=person_tax_unit_ids
136+
)
125137

126138
f.create_group("tax_unit_weight")
127139
f["tax_unit_weight"].create_dataset(TIME_PERIOD, data=tax_unit_weights)
@@ -131,7 +143,9 @@ def create_test_fixture():
131143
f["spm_unit_id"].create_dataset(TIME_PERIOD, data=spm_unit_ids)
132144

133145
f.create_group("person_spm_unit_id")
134-
f["person_spm_unit_id"].create_dataset(TIME_PERIOD, data=person_spm_unit_ids)
146+
f["person_spm_unit_id"].create_dataset(
147+
TIME_PERIOD, data=person_spm_unit_ids
148+
)
135149

136150
f.create_group("spm_unit_weight")
137151
f["spm_unit_weight"].create_dataset(TIME_PERIOD, data=spm_unit_weights)
@@ -141,7 +155,9 @@ def create_test_fixture():
141155
f["family_id"].create_dataset(TIME_PERIOD, data=family_ids)
142156

143157
f.create_group("person_family_id")
144-
f["person_family_id"].create_dataset(TIME_PERIOD, data=person_family_ids)
158+
f["person_family_id"].create_dataset(
159+
TIME_PERIOD, data=person_family_ids
160+
)
145161

146162
f.create_group("family_weight")
147163
f["family_weight"].create_dataset(TIME_PERIOD, data=family_weights)
@@ -151,10 +167,14 @@ def create_test_fixture():
151167
f["marital_unit_id"].create_dataset(TIME_PERIOD, data=marital_unit_ids)
152168

153169
f.create_group("person_marital_unit_id")
154-
f["person_marital_unit_id"].create_dataset(TIME_PERIOD, data=person_marital_unit_ids)
170+
f["person_marital_unit_id"].create_dataset(
171+
TIME_PERIOD, data=person_marital_unit_ids
172+
)
155173

156174
f.create_group("marital_unit_weight")
157-
f["marital_unit_weight"].create_dataset(TIME_PERIOD, data=marital_unit_weights)
175+
f["marital_unit_weight"].create_dataset(
176+
TIME_PERIOD, data=marital_unit_weights
177+
)
158178

159179
# Geography (household level)
160180
f.create_group("state_fips")

policyengine_us_data/tests/test_local_area_calibration/test_stacked_dataset_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
create_sparse_cd_stacked_dataset,
1212
)
1313

14-
FIXTURE_PATH = (
15-
"policyengine_us_data/tests/test_local_area_calibration/test_fixture_50hh.h5"
16-
)
14+
FIXTURE_PATH = "policyengine_us_data/tests/test_local_area_calibration/test_fixture_50hh.h5"
1715
TEST_CDS = ["3701", "201"] # NC-01 and AK at-large
1816
SEED = 42
1917

@@ -151,7 +149,9 @@ def test_counties_match_state(self, stacked_result):
151149
"_AK"
152150
), f"AK county should end with _AK: {county}"
153151

154-
def test_household_count_matches_weights(self, stacked_result, test_weights):
152+
def test_household_count_matches_weights(
153+
self, stacked_result, test_weights
154+
):
155155
"""Number of output households should match non-zero weights."""
156156
hh_df = stacked_result["hh_df"]
157157
expected_households = (test_weights > 0).sum()

0 commit comments

Comments
 (0)