Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Keep the inputs a reform applied after the build stores through reset_calculations

Aperta
#617 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start in core's Simulation.apply_reform and reset_calculations, then follow how input_variables is set at build time and how Holder._set stores values. Read the workaround in policyengine-uk's policyengine_uk/simulation.py to see which keys it logs. Done means a reform's stored inputs survive reset_calculations in core alone, with the override removed and test_reform_inputs_survive_reset.py passing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A reform applied to a simulation after it is built (a Reform passed as reform=, or apply_reform on a built simulation, a clone or a branch) can store inputs with set_input. input_variables is taken when the simulation is built, and reset_calculations deletes the values of every variable it does not name, so a reset deletes what such a reform stored and recalculates the formula instead.

PolicyEngine/policyengine-uk#2075 works around this in policyengine_uk/simulation.py: while Simulation.apply_reform runs, _user_input_keys is replaced by a set subclass that logs each (variable, branch, period) key core adds, and afterwards apply_reform adds to input_variables every logged variable the simulation still holds under a branch it can see (_get_visible_branch_names). That relies on core internals: the name and shape of _user_input_keys, the fact that Holder._set adds a key on every storing route, and _get_visible_branch_names. The country package's tests fail if core changes them (the reform's inputs stop surviving a reset), but the logic belongs in core.

Proposal: core's Simulation.apply_reform records the input keys a reform stores and extends input_variables with them (with a new list, since a clone or branch shares its parent's), so every country package gets this, and policyengine-uk can drop its override. policyengine-uk's test_reform_inputs_survive_reset.py and test_a_reform_applied_later_keeps_what_it_sets_through_a_reset describe the expected behaviour, including inputs a reform replaces, values core does not store, nested reforms and a reform that raises.

Raised in Vahid Ahmadi's review of PolicyEngine/policyengine-uk#2075.

🤖 Generated with Claude Code

Lingua principale
Python
Stelle
22
Fork
30
Merge medio
2g 17h
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PolicyEngine/policyengine-core

Tutte le issue di PolicyEngine/policyengine-core

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.