Repository navigation
X/mR lane order honours an ordered Categorical factor (#144, PR 4) - #152
Merged
cnicholas merged 1 commit intoOct 18, 2026
Merged
Conversation
… factor (#144) The canonical row order in build_keys sorted the raw factor labels, so a stage column with categories before < after gave Xbar/S subgroups in that order (the aggregation groups on the factor column) but X/mR lanes, phases and strata in the order after, before. The canonical sort now uses an ordered Categorical's category codes. Every other input sorts exactly as before: the parallel key is built only when an ordered Categorical is present (xbar_s_sweep: 0 differing lines; golden masters untouched; gate 1547 / 0 / 4; full suite 2638 passed).
cnicholas
force-pushed
the
feat/phased-xmr-phase-stats
branch
from
October 18, 2026 22:21
844abb7 to
3454269
Compare
cnicholas
force-pushed
the
fix/ordered-categorical-lane-order
branch
from
October 18, 2026 22:21
9b45145 to
398aedd
Compare
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.
Part of #144 (PR 4 of 4). Stacked on #151: the base is
feat/phased-xmr-phase-stats, so the diff shows only this change.Summary
DataPreparation.build_keyssorts an ordered pandas Categorical factor by its category codes instead of its labels. Plain string and numeric factors sort exactly as before: the parallel key is built only when an ordered Categorical is present.before < afteralready ordered the Xbar/S subgroups that way (the aggregation groups on the factor column), but X/mR lanes, phases andresult.stratacame outafter, before, because the row order compared the raw labels. The staged Xbar/S docs tell analysts to use labels that sort or an ordered Categorical; the second option now holds on every chart.build_keys. Residuals that run along the lane-major stream (R2 in ADS 2/3) follow the new order for ordered-Categorical inputs, which is the point: the stream should run in stage order.Contract / invariants
sort_values(['cell_key', 'obs_id'])line runs untouched;validation/xbar_s_sweep.pyidentical (0 differing lines); golden masters untouched and passingobs_idremains the tie-break within a cell;sort_keyis still0..N-1Behaviour changes
lane_boundaries,strataand the row order of the analysis frame follow the category order. CSV inputs are never categorical, so the Bishop gate and every reference run are unaffected.Methodology
Tests
tests/test_ordered_categorical_lane_order.py(5): orderedbefore < aftergivesbefore, afteron phased X lanes,strata, phased Xbar phases, the lane divider and the analysis frame; plain strings still sortafter, before; sortable labels need no Categorical; two factors with one ordered sort stage-major then machine; rows within a cell keep source orderpytest tests/— 2638 passed, 7 skippedruff check .mypy processbehavior— 14 errors, all pre-existing, none in data_preparation.pypython validation/e2e_bishop_report.py— 1547 passed, 0 failed, 4 pending;docs/reference/validation.mdunchangedNotes
mainas its base merges.