Repository navigation
Conversation
A researcher's person-level file should load, export and reload without hand fixes. Flat files now number people when no column does, read column names holding two separators, and name the missing column when a group has no ID. Strings and enums map to a group as the value its members share. to_input_dataframe keeps population IDs and declared source inputs, takes a period, and warns about values it leaves out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 1, 2026
A period export dropped inputs the period carries from an earlier one, so a 2023 export of a 2022 file reloaded as defaults. It now holds those values, carried or uprated, and keeps a stored year when the request sits inside it. A month request built a twelve-month period starting in that month instead of the calendar year. A group with no members now maps to an empty string, not "0". to_input_dict warns about left-out formula values as the DataFrame does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
This was referenced Nov 30, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make person-level flat files easier to load, export, and reload. Companion to PolicyEngine/policyengine-us#10574 (state swap) and PolicyEngine/policyengine.py#732 (helper and recipe). Together they support reading a CSV, setting
state_fips, building aDataset.from_dataframe, and passing it to aMicrosimulation.What changes
Loading a flat file
__. Bothsurvey__scoreandsurvey__score__2024can load.ValueErrorthat names the expected columns.Dataset.from_dataframedocuments the format. (policyengine_core/simulations/simulation.py:1123,policyengine_core/data/dataset.py:484)map_toon text and enumsValueError.EnumArrayon every dataset type. The previous default treated enum indices as numbers and aggregated them. Numeric variables still use sums and shares. (policyengine_core/simulations/simulation.py:1584,:1611,:1685)to_input_dataframeTaxBenefitSystem.source_input_variablesdeclares recorded observations for variables that can also have formulas. Both input exporters keep these observations and recorded population IDs. Reforms inherit the declaration. Both exporters warn when they omit a supplied value for another formula variable.policyengine_core/simulations/simulation.py:3387,:3456,:3501,:3598,policyengine_core/reforms/reform.py:139)One changed test
test_subsample_preserves_formula_backed_structural_idsnow expects a recordedperson_idin the input export. A stored ID can determine an entity's random seed after reload. The test still checks that a simulation with a formula-backed ID can be subsampled. (tests/core/test_subsample_invalidates_cache.py:67)Invariants
tests/core/test_map_result_categorical.py:106,:186,:196,tests/core/test_flat_file_property.py:25)tests/core/test_flat_file_datasets.py:258,:297,:315,tests/core/test_flat_file_property.py:93,:113)periodto export all stored periods. Supply the usual person and group columns if those inputs are absent from the unfiltered export. (docs/python_api/simulations.md:15,tests/core/test_flat_file_datasets.py:349)tests/core/test_map_result_categorical.py:163)Migration
Use
calculate("state_code", year, map_to="tax_unit", decode_enums=True)to compare enum labels such as"IA". The default returns anEnumArray. If code needs arithmetic on enum codes, convert the source enum to a numeric array before callingmap_resultand choose the numeric mapping explicitly. (policyengine_core/simulations/simulation.py:1611,docs/python_api/simulations.md:24)Tests
Python 3.13.5, with the editable development install. The full suite passed with 2,899 passed, 4 skipped, and 3 xfailed. The focused checks passed on the fixed checkout and on a local merge with
master.ruff format --checkandruff checkpassed on the changed Python files. Local checks used synthetic fixtures. The Windows matrix, documentation build, country-package smoke jobs, and data-backed microsimulation were outside the local run.axiom: n/a: microsim input handling, no policy change
🤖 Generated with Claude Code