|
26 | 26 | apply_retirement_constraints, |
27 | 27 | reconcile_ss_subcomponents, |
28 | 28 | ) |
| 29 | +from policyengine_us_data.datasets.cps.tipped_occupation import ( |
| 30 | + derive_treasury_tipped_occupation_code, |
| 31 | +) |
29 | 32 |
|
30 | 33 |
|
31 | 34 | class TestVariableListConsistency: |
@@ -201,6 +204,15 @@ def test_se_pension_zeroed_without_se_income( |
201 | 204 | ).all(), "SE pension should be zero without SE income" |
202 | 205 |
|
203 | 206 |
|
| 207 | +class TestTreasuryTippedOccupationCode: |
| 208 | + def test_derive_treasury_tipped_occupation_code(self): |
| 209 | + derived = derive_treasury_tipped_occupation_code( |
| 210 | + np.array([4040, 4110, 4230, 2770, -1, 9999]) |
| 211 | + ) |
| 212 | + |
| 213 | + assert derived.tolist() == [101, 102, 304, 208, 0, 0] |
| 214 | + |
| 215 | + |
204 | 216 | class TestSSReconciliation: |
205 | 217 | """Post-processing SS normalization ensures sub-components sum to total.""" |
206 | 218 |
|
@@ -449,6 +461,7 @@ def test_clone_feature_imputation_rematches_outputs_and_derives_flags( |
449 | 461 | "cps_race": [2, 1], |
450 | 462 | "is_hispanic": [0, 1], |
451 | 463 | "detailed_occupation_recode": [8, 41], |
| 464 | + "treasury_tipped_occupation_code": [101, 304], |
452 | 465 | } |
453 | 466 | ) |
454 | 467 |
|
@@ -486,5 +499,7 @@ def calculate_dataframe(self, columns): |
486 | 499 | assert result["is_male"].tolist() == [1, 0] |
487 | 500 | assert result["cps_race"].tolist() == [2, 1] |
488 | 501 | assert result["is_hispanic"].tolist() == [0, 1] |
| 502 | + if "treasury_tipped_occupation_code" in result.columns: |
| 503 | + assert result["treasury_tipped_occupation_code"].tolist() == [101, 304] |
489 | 504 | assert result["is_computer_scientist"].tolist() == [True, False] |
490 | 505 | assert result["is_farmer_fisher"].tolist() == [False, True] |
0 commit comments