Skip to content

Phase column and phase_statistics on phased X/mR (#144, PR 3) - #151

Merged
cnicholas merged 1 commit into
feat/phased-xbar-sfrom
feat/phased-xmr-phase-stats
Oct 18, 2026
Merged

cnicholas merged 1 commit into
feat/phased-xbar-sfrom
feat/phased-xmr-phase-stats

Conversation

@cnicholas

Copy link
Copy Markdown
Owner

Part of #144 (PR 3 of 4). Stacked on #150: the base is feat/phased-xbar-s, so the diff shows only this change.

Summary

  • What: phased X and mR charts gain what phased Xbar/S got in Phased limits on Xbar and S charts (#144, PR 2) #150: a phase column (the lane label) on the chart data and in chart_table, and result.phase_statistics(chart) with one row per phase (phase, points, center, mR_bar, lpl, upl). On a stratified phased chart (by=['factor 1'], phased=True) the table is per stratum: phase_statistics(chart, stratum=...) or focus(stratum).phase_statistics(chart). The companion mR now reports single_point_phases, which only the solo mR did.
  • Why: today a phased X/mR chart computes each phase's centre, mR-bar and limits and then keeps them only on the rows. The per-phase numbers are the answer the chart gives, and the same accessor should work on every phased chart.
  • Scope: output additions only. The phased arithmetic, row order, limits and signals are unchanged; phased=False charts are untouched.

Contract / invariants

  • Defaults unchanged — unphased X/mR output untouched (the new column and payload key exist only when phased=True); validation/xbar_s_sweep.py identical (0 differing lines)
  • Residuals unaffected
  • Row/index alignment preserved — no rows added, dropped or reordered; lane boundaries unchanged
  • Output schema compatible — additive: phase column after rsg, phases payload key, single_point_phases on the companion mR. Golden masters untouched (none of the scenarios is phased)
  • Pinned error strings unchanged

Behaviour changes

  • Phased X/mR chart data: ['time', 'rsg', 'phase', value, 'center', 'lpl', 'upl', 'beyond_limits', 'obs_id'] (stratified: the by column before phase); chart_table shows phase after subgroup.
  • phase_statistics(chart, stratum=None) works on phased X/mR; on a stratified one it asks for a stratum and names the available ones.
  • Companion mR metadata carries single_point_phases.

Methodology

  • No methodology change — the per-phase values were already computed (10-12 manual Eqs 12-1, 12-5, 12-10, 12-11 per phase); they are now reported

Tests

  • tests/test_phased_limits.py::TestPhaseColumnAndStatistics (5): the phase column equals the lane label and each phase has one centre; the X and mR tables have one row per phase in display order, points sum to the rows, each row's centre and limits match the chart rows, the mR centre is its mR-bar with LPL 0 and the same mR-bar as X; the companion mR carries single_point_phases equal to X's and to the count of phases under two points; stratified tables by stratum equal focus(stratum).phase_statistics, missing or unknown strata are refused; unphased charts have no phase column and refuse phase_statistics, and a stratum on an unstratified chart is refused
  • tests/test_phased_xbar_s.py: the X/mR refusal test became the stratum refusal
  • pytest tests/ — 2633 passed, 7 skipped
  • ruff check .
  • mypy processbehavior — 14 errors, all pre-existing, none in the touched code
  • python validation/e2e_bishop_report.py — 1547 passed, 0 failed, 4 pending; docs/reference/validation.md unchanged

Notes

Phased X and mR charts gain what phased Xbar/S got: a phase column (the lane
label) on the chart data and in chart_table, and result.phase_statistics(chart)
with one row per phase (phase, points, center, mR_bar, lpl, upl). A stratified
phased chart keeps one table per stratum, read with stratum= or through
focus(). The companion mR of a phased X chart now reports single_point_phases,
which only the solo mR did.

Output additions only: the per-phase arithmetic, row order, limits and signals
are unchanged, and phased=False charts are untouched (xbar_s_sweep: 0 differing
lines; gate 1547 / 0 / 4; full suite 2633 passed).
@cnicholas
cnicholas force-pushed the feat/phased-xmr-phase-stats branch from 844abb7 to 3454269 Compare October 18, 2026 22:21
@cnicholas
cnicholas merged commit 0281e6d into feat/phased-xbar-s Oct 18, 2026
17 checks passed
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.

1 participant