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 its ids — 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 with ValueError: length is N while there are N-1 ….
- A tax-benefit system with no group entity cannot be restored at all:
person_count is never assigned and restore_simulation raises UnboundLocalError.
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.
policyengine_core/tools/simulation_dumper.py(inherited verbatim from openfisca-core) rebuilds entity counts from the members mapping instead of the dumped ids:Consequences, all verified against the equivalent code in openfisca-core:
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 ….person_countis never assigned andrestore_simulationraisesUnboundLocalError.Upstream report and reference fix (restore each entity's
countfrom its own dumpedid.npy, which also removes theperson_countplumbing): openfisca/openfisca-core#1387.Happy to open the twin PR here if useful.