Skip to content

Fix self uprating growth and projection counts - #670

Draft
MaxGhenis wants to merge 6 commits into
masterfrom
uprate-self-growth
Draft

MaxGhenis wants to merge 6 commits into
masterfrom
uprate-self-growth

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Self uprating compounds growth per whole year, month, or day. An amount that rises from 1 to 4 over two years projects to 8 in the following year. For extreme ratios, the calculation takes the roots of the endpoints before dividing. Opposite signs are valid over an odd number of intervals. See policyengine_core/parameters/operations/uprate_parameters.py:1153, tests/core/parameters/operations/test_uprating.py:451 and :563.

number counts values after the last explicit date, defaults to ten, and rejects booleans. Tests cover annual, monthly, and daily projections, zero, and the default. The guide explains the cadence measurement window and floating-point rounding at exact boundaries. See policyengine_core/parameters/operations/uprate_parameters.py:353, tests/core/parameters/operations/test_uprating.py:513 and docs/usage/parameters.md:97.

The US parameter search found no self uprating. The three UK self-uprated spending series for DfE, DfT, and DHSC each gain a 2035 projection and have identical 2026 values in both runs. UK parameter sources

This change edits the same uprating module and tests as two companion PRs. The PR that lands later needs to merge the updated master first. #667 · #669

The parameter and period tests passed, including the chained comparison at tests/core/parameters/operations/test_base_uprating_property.py:799. The full suite finished with 4,356 passed, 4 skipped, and 3 expected failures. Ruff format and lint checks passed.

Tests

  • timeout 900 python -m pytest -q -p no:cacheprovider tests/core/parameters/operations/test_uprating.py — 61 passed.
  • timeout 900 python -m pytest -q -p no:cacheprovider tests/core/parameters/operations/test_base_uprating_property.py — 62 passed, including the chained reference. A direct run on tests/fixtures/chained_uprating_reference.py collected zero tests.
  • timeout 900 python -m pytest -q -p no:cacheprovider tests/core/parameters tests/core/test_parameters.py tests/core/test_periods.py — 739 passed.
  • timeout 900 make test-country-template — 39 passed.
  • timeout 900 python -m pytest -q -p no:cacheprovider tests/core/test_pandas3_compatibility.py — 7 passed and 1 skipped in the default environment. With PyArrow available through PYTHONPATH, all 8 passed.
  • timeout 1500 python -m pytest -q -p no:cacheprovider tests — 4,356 passed, 4 skipped, and 3 expected failures.
  • ruff format --check and ruff check passed on all four Python files changed by the PR. git diff --check passed. A Towncrier draft rendered the fragment under Fixed.
  • The country-package smoke tests skipped because the country packages were absent. The US microdata smoke test stayed disabled. The documentation site build was outside the test scope.

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits November 30, 2026 02:47
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
MaxGhenis and others added 4 commits November 30, 2026 17:22
Accept calendar clipping from either endpoint, diagnose a zero starting value, and count future cadence dates.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Compound annual amounts in the reference so valid zero-ending inputs produce a zero projection instead of sharing a synthetic-index division error.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Agent review for Max, written by Codex and posted by Antigravity for Max Ghenis (exact reviewed head 387585cef92ec4cb9fac74b7cef3407c24c410cc).

VERDICT: REQUEST_CHANGES
HEAD: 387585c

The two reported extreme-ratio examples now pass, but the new fallback can turn a correctly rounded finite projection into inf.

Findings

  • P1 — A finite ratio now produces an infinite projection. uprate_parameters.py:1205–1207, applied at :1229. Set annual values to 7.458340731200208e-155 on 2020-01-01 and 1.3407807929942597e154 on 2022-01-01, with parameter: self, from: 2020-01-01, and number: 1. The endpoint ratio is the finite normal float 1.7976931348623155e308. The rounded product start * sys.float_info.max equals the end value, so the new guard takes separate roots and raises the multiplier by one ULP. The 2023 projection is inf at this head. Round 2 produced 1.7976931348623157e308, which also matches my 100-digit Decimal calculation rounded to float. Use the existing ratio-first calculation whenever division yields a finite normal ratio, and add this input as a regression test. Head arithmetic
  • P3 — Growth to zero changes the sign bit. uprate_parameters.py:1186–1187. With annual values -1 in 2020 and 0 in 2022, from: 2020-01-01, and number: 1, the 2023 projection changed from +0.0 to -0.0. I verified the change with math.copysign. The values compare equal. Returning a 0.0 multiplier for a zero endpoint over multiple intervals would preserve the prior result. Zero shortcut

Earlier findings

Finding Status and result
Extreme ratios Partly closed. The ten-year 1e-200 → 1e200 and reverse cases now give 1.0000000000000052e240 and 9.999999999999948e-241, where round 2 gave inf and 0.0. The expected values are 1e240 and 1e-240. For a nonzero subnormal ratio, 1e120 → 9e-203 over ten years, the result improved from 5.6123949559108804e-235 to 5.61909999122821e-235, against 5.6190999912282336e-235 from Decimal. Twenty-one representative ordinary ratios gave identical multipliers and projections. The P1 boundary above is a regression.
Historical cadence window Closed as a documentation gap. The January 2021 to January 2022 window with explicit values 2 and 4 still raises the January 2021 missing-value error, where using that history would give 4 × (4 / 2) = 8 in February 2022. A window starting at the last explicit date gave 8 in February 2023 when configured with that effective date. The documented restriction is acceptable for this PR. Using explicit historical values remains a follow-up. Cadence guard and guide · Guide
Sign changes Closed. 1 → -8 over three years now uses -2 and projects 16. 1 → -4 over two years still raises ValueError. The one-year 1 → -2 case still projects 4, then -8. Sign handling
Downward rounding Closed for this scope as a documented precision limit. For 1 → 1,000 over three years, the exact next amount is 1,000 × 10 = 10,000. Both revisions compute a multiplier of 9.999999999999998, giving 9999.999999999998 before flooring and 9999.0 after. The guide accurately describes the calculation. Rounding guide
Boolean count Closed. With annual values 1 and 2, true previously added 4 and false added nothing. Both now raise the integer-validation error. Integer zero still adds nothing, omission adds ten values, and a June 2023 delayed start still produces January 2024 4 and January 2025 8. Count validation
Stale suite count Closed. The replacement count matches the Linux CI log for a merge tree identical to the reviewed head. Linux CI

One older limit remains visible through the changed branch. With 2**-1074 in 2020, 2**1000 in 2022, 2**-1000 in 2023, and to: 2022-01-01, both revisions project inf in 2024. The amount should be 2**-1000 × 2**1037 = 137438953472. The multiplier overflows even after endpoint rooting. Retaining the multiplier as a mantissa and exponent until application would also address the older one-interval overflow and underflow cases. I would add the exact powers-of-two fixture alongside the new P1 fixture. Growth and application

Sources, description, and merge

  • Numerical sources confirmed. The delta adds no external policy values. CPython defines max as “The maximum representable positive finite float” and min as “The minimum representable positive normalized float.” The new fixture amounts are synthetic. CPython definitions
  • Country claims confirmed. At the description’s pins and both live main tips, the US had zero self-uprating declarations, the UK had three, and neither had a parameter YAML uprating.number key. For DfE, DfT, and DHSC respectively, the merge base and both PR revisions gave identical 2026 results of 107.27934668071654, 31.241724137931033, and 226.85876037091262 £bn. Each first projection is last × (last / prior). Both PR revisions produced identical ten-value series through 2035. The merge base produced nine through 2034. US cutoff snapshot · Pinned UK YAMLs
  • Treasury inputs confirmed. Tables A.2 and A.3, printed pp. 43–44, report “£ billion (current prices).” The resource and capital sums match the UK YAML for FY 2023–24 through 2025–26. DfE 81.8+6.2=88.0, 89.2+5.7=94.9, 94.1+6.8=100.9. DfT 7.9+22.1=30.0, 8.3+20.7=29.0, 8.3+21.8=30.1. DHSC 177.9+10.5=188.4, 193.3+11.6=204.9, 202.0+13.6=215.6. HM Treasury Spring Statement
  • Description. The live title and body match the supplied replacement, with a generated-by footer. GitHub shows no reviews or comments. Line 1 and the changelog fragment overstate extreme-ratio coverage. The fallback applies to nonzero, multi-interval cases, and the P1 example shows it can also switch on a finite normal ratio. The growth, count, guide, and chained-test pointers lead to the stated sections. For precise coverage, point to test_uprating.py:683 and :695 for extreme ratios and odd signs, :536 for booleans, and parameters.md:99 and :101 for cadence and rounding. Line 7’s overlap claim is correct. PR #670 · #667 · #669
  • Merge. The merge base is baf74aa5030f88c766654e4c3bde00db7ddc49e2, also the master snapshot used by the build’s CI. The current master, a310bdf64169d8610a548562690a8de58d46b4ef, has diverged. GitHub reports the PR six commits ahead and 27 behind. The round-3 range is one non-merge commit touching four files, so there were no conflict resolutions to audit. Round-3 range · Current master comparison

Verification

I used Codex (GPT-6). The exact variant and effort were unavailable. Local checks used the GitHub-fetched uprating modules with supporting classes from the existing Python 3.13.9 environment. The 22-case, three-revision probe and four additional two-revision checks exited 0. The country calculation exited 0. Ruff formatting and lint passed on all four PR Python files, eight checks with exit 0. I scanned all 71 Core YAML blobs and found no reader of changed behavior. The two YAML files mentioning uprating are validation fixtures for an external index or misplaced metadata.

The prescribed shared clone failed with transport 'file' not allowed. The import resolved to the existing site-packages install, so I ran zero local checkout pytest files. This includes tests/core/parameters/operations/test_uprating.py, tests/core/parameters/operations/test_base_uprating_property.py, and the direct collection of tests/fixtures/chained_uprating_reference.py. I verified the Linux CI checkout’s tree SHA matches the reviewed head. Its successful run recorded 61 uprating tests, 62 property tests including the chained comparison, 739 parameter and period tests, 39 country-template tests, and 4,356 passed, 4 skipped, 3 xfailed overall. All 19 PR checks succeeded. Linux test log · PR checks

I did not reproduce direct fixture collection, the PyArrow-enabled rerun of tests/core/test_pandas3_compatibility.py, git diff --check, or the Towncrier draft. The CI log records seven passes and one skip in the pandas file, two skips in tests/smoke/test_country_init.py, and one in tests/smoke/test_us.py. The build-only SHA 0950edff5c718a8683713c26797a4a20437cd611 was unavailable from GitHub. The workspace is clean, with no clone or temporary folders left.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant