Keep the inputs a reform applied after the build stores through reset_calculations
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
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
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PolicyEngine/policyengine-core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PolicyEngine/policyengine-core#605 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PolicyEngine/policyengine-core#549 ·
I maintainer di solito rispondono entro 2 giorni
-
`restore_simulation` silently drops memberless group entitiesForse già presa @Adelagric l’ha presa 36 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PolicyEngine/policyengine-core#547 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
PolicyEngine/policyengine-core#621 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
PolicyEngine/policyengine-core#618 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di PolicyEngine/policyengine-core
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
UKGovernmentBEIS/control-arena#917 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
debpalash/VoiceStudio#2937 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aws-samples/sample-per-model-bedrock#261 ·
I maintainer di solito rispondono entro 1 giorno