Stable sort for school escorting#1085
Open
americalexander wants to merge 3 commits into
Open
Conversation
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.
Address multiple locations where the school escorting model does not sort in a stable manner. Also use 64-bit integers for tour and person IDs.
Changes
Stable Sorting
Added
kind=""stable""tosort_valuescalls throughout the school escorting model to ensure deterministic, reproducible results regardless of the initial row ordering of input data. Without stable sorting, ties in the sort key can be broken arbitrarily, leading to non-reproducible outputs across runs or platforms.Affected locations:
determine_escorting_participants: stable sort of chaperones bychaperone_weight(descending) when assigningchaperone_num, and stable sort of escortees byage(ascending) when assigningescortee_numschool_escorting: stable sort of school escort tours byhousehold_idandschool_escort_directionbefore further processingcreate_pure_school_escort_tours: stable sort of pure escort tours byhousehold_id,person_id, andstarttime64-bit Integer Types
Replaced
.astype(int)with.astype(""int64"")for tour IDs, person IDs, and related integer columns. Using the platform-nativeinttype can produce 32-bit integers on Windows, which risks integer overflow for large ID values and inconsistent behavior across operating systems.Affected locations:
chauf_numandchauf_idincreate_school_escorting_bundles_tablejoin_attributestour_idincreate_chauf_escort_tripsnum_escorteesinprocess_tours_after_escorting_model