Skip to content

Commit 0826eea

Browse files
authored
Merge pull request #390 from PolicyEngine/daphnehanse11/issue388
Fix last SSN Issues
2 parents 7128d05 + 072176e commit 0826eea

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
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: patch
2+
changes:
3+
fixed:
4+
- Clean up immigration status PR.

policyengine_us_data/datasets/cps/cps.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def generate(self):
6666
cps,
6767
person,
6868
spm_unit,
69+
self.time_period,
6970
undocumented_target=13e6,
7071
undocumented_workers_target=8.3e6,
7172
undocumented_students_target=0.21 * 1.9e6,
@@ -706,6 +707,7 @@ def add_ssn_card_type(
706707
cps: h5py.File,
707708
person: pd.DataFrame,
708709
spm_unit: pd.DataFrame,
710+
time_period: int,
709711
undocumented_target: float = 13e6,
710712
undocumented_workers_target: float = 8.3e6,
711713
undocumented_students_target: float = 0.21 * 1.9e6,
@@ -1390,8 +1392,7 @@ def get_arrival_year_midpoint(peinusyr):
13901392

13911393
# Calculate arrival years once for all logic
13921394
arrival_years = get_arrival_year_midpoint(person.PEINUSYR)
1393-
CURRENT_YEAR = 2024
1394-
years_in_us = CURRENT_YEAR - arrival_years
1395+
years_in_us = time_period - arrival_years
13951396
age_at_entry = np.maximum(0, person.A_AGE - years_in_us)
13961397

13971398
# start every non-citizen as LPR so no UNSET survives
@@ -1414,10 +1415,11 @@ def get_arrival_year_midpoint(peinusyr):
14141415

14151416
# 3. Cuban / Haitian entrants (created by Congress in 1980)
14161417
# Only those who arrived after 1980
1418+
CUBAN_HAITIAN_ARRIVAL_CUTOFF = 1980
14171419
cuban_haitian_mask = (
14181420
(ssn_card_type != 0)
14191421
& np.isin(birth, list(COUNTRY_CODES["CUBAN_HAITIAN"]))
1420-
& (arrival_years >= 1980)
1422+
& (arrival_years >= CUBAN_HAITIAN_ARRIVAL_CUTOFF)
14211423
)
14221424
immigration_status[cuban_haitian_mask] = "CUBAN_HAITIAN_ENTRANT"
14231425

@@ -1446,19 +1448,6 @@ def get_arrival_year_midpoint(peinusyr):
14461448
)
14471449
immigration_status[mask] = "TPS"
14481450

1449-
# ---------------------------------------------------------------
1450-
# Map custom labels into Enum-approved buckets
1451-
placeholder_to_specific_status = {
1452-
"TEMP_NONQUALIFIED": "TPS",
1453-
}
1454-
needs_translation = np.isin(
1455-
immigration_status, list(placeholder_to_specific_status.keys())
1456-
)
1457-
immigration_status[needs_translation] = (
1458-
pd.Series(immigration_status[needs_translation])
1459-
.replace(placeholder_to_specific_status)
1460-
.values
1461-
)
14621451
# Final write (all values now in ImmigrationStatus Enum)
14631452
cps["immigration_status"] = immigration_status.astype("S")
14641453
# ============================================================================

0 commit comments

Comments
 (0)