Skip to content

[PULL REQUEST] Sort needed before integerize_1d function#103

Open
GregorSchroeder wants to merge 2 commits intomainfrom
102-bug-sort
Open

[PULL REQUEST] Sort needed before integerize_1d function#103
GregorSchroeder wants to merge 2 commits intomainfrom
102-bug-sort

Conversation

@GregorSchroeder
Copy link
Contributor

Describe this pull request. What changes are being made?

The integerize_1d function implemented in #98 with the "weighted_random" methodology requires the data to be explicitly sorted to avoid any issues with stochastic variation from run to run. This pull request adds explicit sorts before usage.

What issues does this pull request address?

closes #102

@GregorSchroeder GregorSchroeder self-assigned this Feb 6, 2026
@GregorSchroeder GregorSchroeder added the enhancement New feature or request label Feb 6, 2026
@GregorSchroeder GregorSchroeder linked an issue Feb 6, 2026 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds explicit sorting before calling integerize_1d to make the weighted-random integerization deterministic and consistent across runs.

Changes:

  • Sort intermediate demographic frames by race, sex, age before integerization in annual cycle calculations.
  • Sort pop_df before integerizing population in the main pipeline.
  • Minor formatting adjustments around round(...) calls.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/annual_cycle.py Adds sort_values(["race","sex","age"]) ahead of integerization in births/deaths/migration/newborns flows.
main.py Sorts pop_df in-place before integerize_population to stabilize row order.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Missing Sorts before integerize_1d usage

1 participant