Skip to content

fix: plot trapezoidal trajectories with empty motion phases - #910

Open
Afloat16 wants to merge 2 commits into
petercorke:mainfrom
Afloat16:fix/trapezoidal-empty-plot-phases-20261030
Open

Afloat16 wants to merge 2 commits into
petercorke:mainfrom
Afloat16:fix/trapezoidal-empty-plot-phases-20261030

Conversation

@Afloat16

@Afloat16 Afloat16 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Trajectory.plot previously indexed the first coast or deceleration sample even when that phase was empty, raising IndexError for valid triangular, stationary, sparsely sampled or zero-blend trajectories.

Draw a phase-joining segment only when the phase contains a sample, preserving the trajectory arrays and the normal plotting path.

Numerical results and public behavior

Numerical trajectory values and public signatures are unchanged. Plotting completes when a motion phase is empty and preserves every input sample.

Regression coverage

Five phase configurations in both travel directions and with zero/nonzero time origins. The regressions check actual Matplotlib data and input immutability. Zero-blend plotting uses a real Trajectory with finite constant-velocity data, so the plotting check does not depend on the separate generator issue.

On the unchanged original baseline, the 20 new regression cases reported 16 failures and 4 passes; all 20 pass with the fix.

Recorded focused validation

The earlier follow-up run used Linux and Python 3.12.14. The selected suites reported 51 passed, 18 subtests passed.

MPLBACKEND=Agg PYTHONPATH=src python -m pytest -q tests/test_trapezoidal_empty_plot_phases.py tests/test_trajectory.py tests/test_trajectory_typing_fixes.py tests/test_trapezoidal_profile.py

The result above is the previously recorded focused run. The new regression test files passed Ruff lint and formatting, and git diff --check passed. Full local repository, local documentation and local cross-platform runs are outside that result.

Current branch and hosted CI

The branch includes upstream main at 879fb363580840e19ee70b6b175e8cd3543e2b38; current head: 8b0c46a112d462fc327594180f33a024b7b1f903.

Current-head CI is successful, including mypy, core tests, the Linux/macOS/Windows test matrix and the documentation build. The docs-deploy and Dependabot auto-merge checks are skipped in their applicable workflow context.

The separate zero-blend generator issue is tracked in #924, including the minimal reproduction and normal-blend controls.

Checklist

  • Final diff reviewed and validation results checked.
  • Regression tests cover the affected behavior.
  • Numerical and public behavior changes are stated above.
  • Branch updated from main.
  • Current hosted CI passes.
  • PR is ready for review.

Co-Authored-By: ChatGPT (GPT-6 Astra Pro)
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke

Copy link
Copy Markdown
Owner

Thank you. The change looks right to me.

Could you read the diff yourself and tick the "personally read, run and understood" box? Then please update the branch from main (that clears the red mypy, now fixed) and mark it ready for review.

You mention a separate problem in the zero-blend trajectory generator. Could you file an Issue for it?

@Afloat16

Afloat16 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

I have reviewed the final diff and the validation results. The branch includes main at 879fb363, and the PR is ready for review. CI for 8b0c46a1 passes, including mypy. The separate zero-blend generator problem is filed as #924, with the minimal reproduction and finite-profile controls; this PR remains scoped to empty-phase plotting.

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.

2 participants