`restore_simulation` silently drops memberless group entities
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in policyengine_core/tools/simulation_dumper.py at restore_simulation, then compare the inherited implementation with the reference fix in openfisca/openfisca-core#1387. Done means restored entity counts match the dumped ids, memberless group entities remain present, and simulations without group entities restore without UnboundLocalError.
Written by the indexing model from the issue text.
Description
policyengine_core/tools/simulation_dumper.py (inherited verbatim from openfisca-core) rebuilds entity counts from the members mapping instead of the dumped ids:
person_count = len(population.members_entity_id)
population.count = max(population.members_entity_id) + 1
Consequences, all verified against the equivalent code in openfisca-core:
- A group entity with no member is silently dropped from the restored simulation's
count, while still listed in itsids— an internally inconsistent state. Calculations on the restored simulation then return arrays with one entity missing, with no error. If a value was stored for the group entity, restoring instead fails withValueError: length is N while there are N-1 …. - A tax-benefit system with no group entity cannot be restored at all:
person_countis never assigned andrestore_simulationraisesUnboundLocalError.
Upstream report and reference fix (restore each entity's count from its own dumped id.npy, which also removes the person_count plumbing): openfisca/openfisca-core#1387.
Happy to open the twin PR here if useful.
- Dominant language
- Python
- Stars
- 22
- Forks
- 30
- Avg merge
- 14h 33m
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PolicyEngine/policyengine-core
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
download_huggingface_dataset sends no token for public+gated repos (private is the wrong predicate) Open
Difficulty 2/5 1-2 days Newbie friendliness 74/100
PolicyEngine/policyengine-core#529 · 1 comment ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 74/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in PolicyEngine/policyengine-core
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100