Skip to content

Fix measurement alignment in goodness-of-fit and residual plots - #612

Open
ChenYueqi2024 wants to merge 2 commits into
PEtab-dev:mainfrom
ChenYueqi2024:fix/diagnostic-plot-alignment-247
Open

ChenYueqi2024 wants to merge 2 commits into
PEtab-dev:mainfrom
ChenYueqi2024:fix/diagnostic-plot-alignment-247

Conversation

@ChenYueqi2024

Copy link
Copy Markdown

Fixes #247.

Goodness-of-fit and residual-versus-simulation plots currently pair values by row position, although residual calculation matches measurement metadata. Shuffling simulation rows therefore changes scatter points and regression statistics; repeated measurements backed by a single simulation row can also cause unequal-length errors.

Extract the existing residual calculation lookup into a shared private helper and use the same matching/ambiguity rules to align plotted simulation values with measurement order. This preserves replicate points, measurement-aligned colors, empty optional fields, and the input tables. Add a changelog fragment and four regression cases covering both plots, shuffled rows, multiple observables/conditions, repeated measurements, and duplicate DataFrame indices.

Validation on Windows / Python 3.12:

  • All four new regression cases fail on the original implementation and pass with the fix.
  • Visualization, calculation and new regression tests: 38 passed.
  • Broader v1 suite: 205 passed, 2 skipped, excluding math/test_math.py, test_model_pysb.py, and test_priors.py because the optional PySB/benchmark dependencies were not installed. The full v2 suite was not run.
  • Repository-pinned Ruff 0.16.2 lint and formatting checks pass for changed Python files; git diff --check passes.
  • The pre-commit wrapper could not initialize its hook repository because GitHub's Git endpoint was unreachable; this is not a claim that all hooks passed.

Implemented and validated with OpenAI Codex assistance.

@ChenYueqi2024
ChenYueqi2024 requested a review from a team as a code owner November 19, 2026 10:30
Copilot AI balanced review requested due to automatic review settings November 19, 2026 10:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

Wrong plot_goodness_of_fit if different order of rows in measurement_df and simulation_df

2 participants