Skip to content

Skip redundant dataset copy in apply_uprating - #1523

Merged
nwoodruff-co merged 1 commit into
mainfrom
fix/apply-uprating-redundant-copy
Mar 10, 2026
Merged

nwoodruff-co merged 1 commit into
mainfrom
fix/apply-uprating-redundant-copy

Conversation

@nwoodruff-co

Copy link
Copy Markdown
Contributor

Summary

  • Adds a copy parameter (default True) to apply_uprating so callers can opt out of the defensive deep copy of the full multi-year dataset
  • extend_single_year_dataset now passes copy=False since it already copies each year individually via dataset.copy() — the second copy was redundant
  • External callers of apply_uprating retain the existing safe-by-default behaviour

This is the proper upstream fix for the monkey-patch used in policyengine.py#251 to avoid the redundant copy in the UK simulation run.

Test plan

  • Existing tests pass
  • Benchmark in policyengine.py#251 confirms no change in output values after removing the monkey-patch

…_single_year_dataset

Add copy=False parameter to apply_uprating; extend_single_year_dataset passes
copy=False since it already copies each year individually via dataset.copy().
This removes the unnecessary deep copy of the entire multi-year dataset.
@nwoodruff-co
nwoodruff-co merged commit 1f31a8d into main Mar 10, 2026
2 checks passed
@nwoodruff-co
nwoodruff-co deleted the fix/apply-uprating-redundant-copy branch March 10, 2026 10:53
vahid-ahmadi added a commit that referenced this pull request Oct 8, 2026
#1209 reported PolicyEngine UK producing slightly different aggregates
on ubuntu-latest vs macos-latest CI. The triage narrowed it to
dict-iteration-order differences in apply_uprating's tree walk
(closed fix attempt PR #1223).

A series of follow-on PRs since rebuilt the affected uprating code
path:

- #1254 added multi-year datasets and separated uprating into a
  discrete pipeline step;
- PRs #1543 / #1544 / commit 13a4ac7 rebuilt uprate_rent which was
  the primary visible site of divergence;
- #1523 skipped a redundant dataset copy in apply_uprating.

CI runs on ubuntu-latest only, so there's no live cross-OS test to
prove the issue is fully resolved. Persist the diagnosis as a known-
issue page so that, if reproducibility regression resurfaces, the
next person doesn't have to re-derive the root-cause shape.

Includes a sketched minimal regression test for reintroducing
deterministic ordering once a cross-OS CI matrix is restored.
vahid-ahmadi added a commit that referenced this pull request Oct 12, 2026
#1209 reported PolicyEngine UK producing slightly different aggregates
on ubuntu-latest vs macos-latest CI. The triage narrowed it to
dict-iteration-order differences in apply_uprating's tree walk
(closed fix attempt PR #1223).

A series of follow-on PRs since rebuilt the affected uprating code
path:

- #1254 added multi-year datasets and separated uprating into a
  discrete pipeline step;
- PRs #1543 / #1544 / commit 13a4ac7 rebuilt uprate_rent which was
  the primary visible site of divergence;
- #1523 skipped a redundant dataset copy in apply_uprating.

CI runs on ubuntu-latest only, so there's no live cross-OS test to
prove the issue is fully resolved. Persist the diagnosis as a known-
issue page so that, if reproducibility regression resurfaces, the
next person doesn't have to re-derive the root-cause shape.

Includes a sketched minimal regression test for reintroducing
deterministic ordering once a cross-OS CI matrix is restored.
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.

2 participants