diff --git a/changelog.d/py-dataset-inputs.fixed.md b/changelog.d/py-dataset-inputs.fixed.md new file mode 100644 index 000000000..d0fa5b16f --- /dev/null +++ b/changelog.d/py-dataset-inputs.fixed.md @@ -0,0 +1 @@ +Update the PolicyEngine bundle to 6.20.5. From 6.0.0 to 6.20.4, .py built US simulations from a dataset without listing most of the dataset's inputs, so policyengine-us recalculated marginal tax rates without the household's income other than earnings, its age and its location, and `target=cliff` economy results counted the lost income as cliff gaps. 6.20.5 lists the inputs, so US marginal tax rates and `target=cliff` results calculated from datasets keep the household's inputs. US labor supply responses, which read marginal tax rates, change too: in .py's example, one earner's response to a reform moves from -$591.09 to policyengine-us's -$655.38. diff --git a/docker/Dockerfile b/docker/Dockerfile index 8bd039ae1..38010a492 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ FROM python:3.12 # Match the API bundle in pyproject.toml; the bundle updater changes both pins. # The models extra pins the complete certified runtime package set. -RUN pip install "policyengine[models]==6.20.4" ipython +RUN pip install "policyengine[models]==6.20.5" ipython diff --git a/pyproject.toml b/pyproject.toml index d5ed03c6b..03645560c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ # versions certified by this PolicyEngine bundle. Cloud Run installs the # complete frozen environment from uv.lock; the generic image installs # this requirement directly. - "policyengine[models]==6.20.4", + "policyengine[models]==6.20.5", # The simulation service's generated client, which builds the requests of # API v2's household calculation, simulation and report routes, and the # one-time migration command's run-free report create diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py index 7f74cbd0e..cf9ce425f 100644 --- a/tests/unit/test_constants.py +++ b/tests/unit/test_constants.py @@ -47,6 +47,12 @@ def find_spec(self, fullname, path=None, target=None): # incomes in the order of their rows (PolicyEngine/policyengine.py#777). FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT = Version("6.20.4") +# The first .py release whose US simulations built from a dataset list every +# stored dataset column in ``input_variables``, so policyengine-us's +# ``marginal_tax_rate`` recalculates net income with the household's inputs +# (PolicyEngine/policyengine.py#783). +FIRST_RELEASE_RECORDING_DATASET_INPUTS = Version("6.20.5") + class TestBundleDatasetDisplayLabels: @pytest.mark.parametrize( @@ -343,6 +349,24 @@ def test__requests_name_a_release_that_sorts_incomes_stably(self): assert installed_version == POLICYENGINE_VERSION assert Version(installed_version) >= FIRST_RELEASE_WITH_STABLE_INEQUALITY_SORT + def test__requests_name_a_release_that_records_dataset_inputs(self): + """API v1's economy requests run on a .py release that records dataset inputs. + + Economy requests send ``POLICYENGINE_VERSION`` as + ``policyengine_version``, and the simulation service runs each request + on the app it deployed for that version. From 6.0.0 up to the release + in ``FIRST_RELEASE_RECORDING_DATASET_INPUTS``, .py built a US + simulation from a dataset without listing most of the dataset's + columns in ``input_variables``. policyengine-us's ``marginal_tax_rate`` + raises the earnings of each of the household's two adults with the + highest market income in a branch of the simulation that deletes every + variable not in that list, then recalculates household net income. + The branch lost the household's income other than earnings, its age + and its location, so marginal tax rates were wrong, and + ``target=cliff`` results counted the lost income as cliff gaps. + """ + assert Version(POLICYENGINE_VERSION) >= FIRST_RELEASE_RECORDING_DATASET_INPUTS + def test__uses_policyengine_bundle_versions_for_us_uk_and_core(self): expected_versions = self._expected_bundle_versions() assert expected_versions["policyengine"] == POLICYENGINE_VERSION diff --git a/uv.lock b/uv.lock index c5dbfede2..424a301f3 100644 --- a/uv.lock +++ b/uv.lock @@ -2954,7 +2954,7 @@ wheels = [ [[package]] name = "policyengine" -version = "6.20.4" +version = "6.20.5" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "h5py" }, @@ -2966,9 +2966,9 @@ dependencies = [ { name = "pydantic" }, { name = "requests" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/32/77/e2970d5839f497d6fefd06aeef99774859ca2f30bb5ee1691dfb458a7e2c/policyengine-6.20.4.tar.gz", hash = "sha256:4f253587872230fd55e8c045622ccd913ada304c1ead9b60dbc33cf4315685cf", size = 1868173, upload-time = "2026-12-01T01:43:30.923Z" } +sdist = { url = "https://files.pythonhosted.org/packages/c3/25/06d21a495fdb08d5ca28c2fce7a3c02fa054a65647d3a64f5d882261590c/policyengine-6.20.5.tar.gz", hash = "sha256:9ae71e19ba440bedede2e0b61b42a64cb969749df808dba50c28ef14874a441f", size = 1871654, upload-time = "2026-12-02T20:46:20.663Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fc/92/02d046bf927873476ebf3e54e3efd23acd7270b221bca00d972f69086312/policyengine-6.20.4-py3-none-any.whl", hash = "sha256:0b93ec55feab0edfde61dcf27ecb81c68e1f7a271bd328a0ddf0e92f54933301", size = 775042, upload-time = "2026-12-01T01:43:28.788Z" }, + { url = "https://files.pythonhosted.org/packages/53/a0/6dcb72b7925453eeb322d340f9c5de4a5ffbfd0b711c12f57cb757ed0193/policyengine-6.20.5-py3-none-any.whl", hash = "sha256:ed35016f2bc62a6176e2da3c8ad34dd6f386b424369fc71a9ea3d05e387cfc54", size = 775369, upload-time = "2026-12-02T20:46:18.59Z" }, ] [package.optional-dependencies] @@ -3073,7 +3073,7 @@ requires-dist = [ { name = "mypy", marker = "extra == 'dev'", specifier = ">=1.15,<2" }, { name = "openai" }, { name = "packaging", specifier = ">=24,<27" }, - { name = "policyengine", extras = ["models"], specifier = "==6.20.4" }, + { name = "policyengine", extras = ["models"], specifier = "==6.20.5" }, { name = "policyengine-api-simulation-client", specifier = "==0.20261202.458" }, { name = "policyengine-observability", extras = ["flask", "google", "httpx", "otlp-grpc"], specifier = ">=3.0.3,<4" }, { name = "psycopg", extras = ["binary"], specifier = ">=3.3,<4" },