Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/spm-release-pin.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pin the reviewed SPM Calculator 0.5.0 development commit for reproducible threshold corrections, including the revised 2019–2024 series and published 2025 continuation. Preserve legacy housing-share constants and CPI-U extrapolation. Replace the Git pin with exactly 0.5.0 only during coordinated package promotion.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Regression tests for the spm_unit_spm_threshold formula.

Verifies that:
1. Historical published years (2015-2024) match the Census Bureau's
1. Historical published years (2005-2025) match the Census Bureau's
published Betson reference thresholds exactly (via spm-calculator).
2. Post-published years uprate via PolicyEngine's ``gov.bls.cpi.cpi_u``
parameter.
3. Composition and tenure changes between periods flow through to the
threshold while applying the unit-specific geographic adjustment.
4. The Betson three-parameter equivalence scale is applied (a 2A2C
reference family at the renter national base equals 39430 in 2024).
reference family at the corrected renter national base equals 39219.893902 in 2024).
"""

import numpy as np
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_reference_threshold_matches_census_for_published_years():


def test_reference_threshold_uprates_with_cpi_u_past_latest_published():
"""Post-2024 reference threshold must equal the latest published
"""Post-published reference threshold must equal the latest published
value scaled by PolicyEngine's CPI-U ratio."""
cpi_u = _cpi_u()
latest = LATEST_PUBLISHED_SPM_THRESHOLD_YEAR
Expand Down Expand Up @@ -259,3 +259,23 @@ def test_prior_threshold_does_not_imply_geographic_adjustment():
got = float(sim.calculate("spm_unit_spm_threshold", YEAR)[0])
expected = current_base * equiv
assert got == pytest.approx(expected, rel=1e-5)


@pytest.mark.parametrize(
"year,tenure,expected",
[
(2024, SPMUnitTenureType.OWNER_WITH_MORTGAGE, 39230.994457),
(2024, SPMUnitTenureType.OWNER_WITHOUT_MORTGAGE, 32878.594848),
(2024, SPMUnitTenureType.RENTER, 39219.893902),
(2025, SPMUnitTenureType.OWNER_WITH_MORTGAGE, 41322.707394),
(2025, SPMUnitTenureType.OWNER_WITHOUT_MORTGAGE, 34325.997720),
(2025, SPMUnitTenureType.RENTER, 41700.555713),
],
)
def test_reviewed_bls_correction_and_2025_continuation(year, tenure, expected):
# Literal workbook values, independent of the installed package's table.
# 2024 revised segment: https://www.bls.gov/pir/spm/spm_thresholds_2024_correction.htm
# 2025 continuation: https://www.bls.gov/pir/spmhome.htm
assert LATEST_PUBLISHED_SPM_THRESHOLD_YEAR == 2025
actual = _reference_threshold_array(np.array([tenure]), year, _cpi_u())[0]
assert actual == pytest.approx(expected, abs=0.000001, rel=0)
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
# extension and is available on every supported Python version.
"pandas>=3.0",
"policyengine-core>=3.30.1",
"spm-calculator>=0.2.0",
"spm-calculator @ git+https://github.com/PolicyEngine/spm-calculator@9e6ae4798458771231613b994df2345dd1685214",
"tables>=3.9",
"tqdm>=4.67.1",
]
Expand All @@ -47,6 +47,9 @@ dev = [
"towncrier>=24.8.0",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["policyengine_us"]

Expand Down
115 changes: 40 additions & 75 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading