Support root populations: entities that are not built over persons
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start by tracing TaxBenefitSystem.init and instantiate_entities, then follow population handling through Simulation._bind_to_tax_benefit_system, Simulation.clone, commons/formulas.py, and SimulationBuilder.build_from_dict. Check the existing tests for these paths and add coverage for a root entity alongside the current person and group populations. Done means root populations are created, preserved by binding and cloning, handled as specified for formulas, exports, subsampling, and builder input, while systems without roots keep existing behavior.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Background
PolicyEngine/policyengine-uk#2940 adds a firm entity. A firm population is not a group of persons:
- firms have their own ids and weights;
- no person belongs to a firm (a person-to-firm job link may come later);
- firm and household formulas never read each other.
Core has no entity type for this, so the UK PR works around core, and the workarounds are the risk.
What core assumes today
Read from core 3.34.9; the UK workarounds below are still in use, and pass, on master (3.37.2). Core treats every non-person entity as a GroupPopulation over the single person population:
TaxBenefitSystem.__init__keeps the firstis_personentity as the person entity and treats every other entity as a group.instantiate_entitiesbuilds only the person population and group populations.Simulation._bind_to_tax_benefit_systemraises for any other population, andSimulation.clonecopies only person and group populations, so another population is silently lost.commons/formulas.pycallsentity.sum/all/max/minfor non-person entities, which a plainPopulationlacks.SimulationBuilder.build_from_dictsilently ignores an unknown plural, such as afirms:block besidepeople.
What the UK PR has to do instead
- Registers
Firmas a plainEntity, listed afterPerson. Core then marks itis_person=True, so downstream code that readsis_personsees two person entities. That forces PolicyEngine/policyengine.py#765 and PolicyEngine/policyengine-api#4339. - Replaces two methods on core's own classes at import:
TaxBenefitSystem.instantiate_entities(to add aRootPopulation) andSimulation.clone. Both replacements pass through when there are no root populations, but they apply to every model in the process, for example when policyengine.py loads the US and UK models side by side. - Depends on core private names. It imports
_branch_clonewithout a fallback in two modules (simulation.py,tax_benefit_system.py; main'sutils/subsample.pyalready imports it with one) and reads_holders,_memory_storage,_get_exportable_input_periods,_to_person_dataframeand_bind_to_tax_benefit_system. A rename would breakimport policyengine_ukfor every user, not only firm users. - Adds about 350 lines to the UK
Simulationfor binding, cloning, exports,map_resultand the situation and dataset builders.
Until core supports root populations, policyengine-uk caps core below the next minor version and runs its firm and core-internals tests against core's master in a separate CI workflow.
Proposal
A first-class root entity type, for example build_entity(..., is_root=True), that:
- is neither the person entity nor a group, and is not reported as
is_person; - gets its own population from
instantiate_entities; - is kept by bind, clone and branch;
- makes
map_resultand projections raise across roots; - is skipped in person-level exports and subsampling (or exported as its own table);
- is accepted by
SimulationBuilderas its own plural block.
Systems without root entities behave exactly as before. A many-to-many link (person-to-firm jobs) could follow later.
If core would rather not
The fallback in policyengine-uk is a separate firm simulation that shares the parameter tree. It needs no core patches, because firms and households never meet inside a formula, but it loses a single simulation object for reforms that touch both sides.
- Linguagem predominante
- Python
- Estrelas
- 22
- Forks
- 31
- Merge médio
- 1d 19h
- PRs com merge (30d)
- 14
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de PolicyEngine/policyengine-core
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
PolicyEngine/policyengine-core#605 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
PolicyEngine/policyengine-core#549 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
PolicyEngine/policyengine-core#665 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Population.__call__ passes unweighted=True to calculate_add and calculate_divide, which reject itAberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
PolicyEngine/policyengine-core#659 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 18/100
PolicyEngine/policyengine-core#656 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de PolicyEngine/policyengine-core
Issues semelhantes
-
claude-subscription-directsdk: tool calls with raw control characters in string values are droppedAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
NousResearch/hermes-official-plugins#538 ·
Mantenedores costumam responder em até 3 dias
-
bug(qdiffusion): EnergyModel.score_visible_logits computes biased visible/hidden on-ratios when solver returns variable solution counts per candidateTalvez já em andamento @houzhongyu assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
qboson/kaiwu-pytorch-plugin#2133 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
MakazhanAlpamys/Soup#3415 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias