Skip to content

Allow intermediate geographies between meta and seed levels - #225

Open
nick-fournier wants to merge 5 commits into
ActivitySim:masterfrom
nick-fournier:feat/intermediate-geographies-clean
Open

nick-fournier wants to merge 5 commits into
ActivitySim:masterfrom
nick-fournier:feat/intermediate-geographies-clean

Conversation

@nick-fournier

@nick-fournier nick-fournier commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

With a geography between the meta and seed levels, meta-control factoring previously requested an intermediate target from the seed control table and raised a KeyError. Filter those intermediate targets consistently during meta-control factoring, final seed balancing, and seed integerization, allowing hierarchies such as REGION > DISTRICT > PUMA > TRACT > TAZ to complete.

Supersedes #217 and builds on the stabilization work merged in #219. Preserves @JoeJimFlood's original feature and initial regression-test commits, with their original authorship, followed by focused cleanup. The replacement omits #217's dependency, CI, platform-specific baseline, and test-stabilization experiments. Basically we can close #217, this cherry-picked the important bits and builds on the CI-testing stabilization of #219.

  • Keep the intermediate example's unique controls and crosswalk, and inherit shared configuration and data instead of duplicating them.
  • Test one and two intermediate levels with fractional and integerized weights, including household expansion and aggregate summaries for each intermediate level.
  • Document that intermediate controls remain available in control tables and summaries but are not distributed to seed zones or enforced during seed balancing or integerization; meta controls continue to be factored into seed controls.

Validation: Ruff passes; the full local suite passes (41 tests) on Windows / Python 3.12, including all four feature scenarios. Independently replacing each changed step with its upstream implementation causes the integerized regression to fail on the missing target or mismatched control columns. All 15 existing CI jobs pass on Windows, Linux, and macOS across Python 3.10–3.14.

JoeJimFlood and others added 5 commits October 5, 2026 10:05
The test ran the pipeline and asserted nothing, so it only caught a
crash. Give it the isolation the rest of the suite has and check what
the feature actually does.

Reverting the control_spec filtering now fails this test with
KeyError: "['persons_occ_1'] not in index" from meta_control_factoring,
so completing the run is itself meaningful -- but the run alone does not
pin which controls survive where. It now also asserts that the
intermediate geography's control is kept out of the seed-level control
table, that the meta geography's controls are still factored into it,
and that the intermediate control still constrains its own geography
rather than being discarded.

Adds a setup_function restoring the decorated `settings` injectable.
Without it this module inherits whatever settings an earlier test
pinned, and fails on a `geographies` list that is not its own.

Also asserts sub-geography balancing conserves the seed household total,
and that expand_households produces nothing, since this example sets
NO_INTEGERIZATION_EVER.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Seven of the twelve fixture files were byte-identical copies of the
base example_test fixtures: seed_households.csv, seed_persons.csv,
taz_controls.csv, tract_controls.csv, repop_taz_controls.csv,
logging.yaml and repop_controls.csv -- 429 of the example's 728 lines.
The two repop files were never exercised at all, since the test runs no
repop steps.

configs_dir and data_dir both resolve through
config.cascading_input_file_path, which accepts a list of directories
and takes the first one holding a given file, so the test can layer the
intermediate directories over the base example. That is already how
tests/test_steps.py supplies its configs.

The *_intermediate directories now carry only what this example really
changes: its settings and controls, the crosswalk with the extra
geography levels, and the DISTRICT and REGION control data.

Beyond the size, the copies were a correctness risk: editing a seed
table in examples/example_test/data would have left this example
testing stale inputs with no indication anything had diverged.

Verified: full suite passes on python 3.12 / pandas 3.0.3 and on
python 3.10 / pandas 2.3.3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nick-fournier
nick-fournier marked this pull request as ready for review October 5, 2026 17:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants