Skip to content

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

Draft
Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/trapezoidal-empty-plot-phases-20261030
Draft

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

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Summary

Trajectory.plot indexes the first coast or deceleration sample even when the corresponding phase is empty, raising IndexError for valid triangular, stationary, sparsely sampled or zero-blend trajectories.

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

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

The implementation, regression tests and this description were prepared with ChatGPT (GPT-6 Astra Pro). Afloat16 requested the work and authorised submission; human review of this diff has not yet been confirmed, so this PR is a draft.

Related issue

Found through code inspection; no specific issue is linked. The current open PRs were checked for competing fixes.

Validation

The new regressions on the unchanged base report 16 failed, 4 passed (20 new regression cases on the unchanged base). With this change: 20 new regression cases pass; selected trajectory suites: 51 passed, 18 subtests passed.

Five phase configurations in both travel directions and with zero/nonzero time origins; actual Matplotlib data and input immutability are checked. The zero-blend cases use a real Trajectory containing finite constant-velocity data, isolating plotting from a separate generator issue.

Tested on 9f282d8ff952a6ca95d340ae6a62b04e545a302f using Linux/Python 3.12.14 and the actual package with matching native extensions enabled.

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

New test files pass Ruff lint and format checks; git diff --check passes. Existing production-file Ruff diagnostics are unchanged. Mypy reports the same existing Link.py:327 return-type error on the unchanged base and this branch (165 source files checked), with no additional diagnostics. It does not pass cleanly.

Focused suites only; the complete repository suite, docs build and cross-platform CI were not rerun.

Checklist

  • Issue claimed, if a corresponding issue is identified.
  • PR title follows Conventional Commits.
  • Full repository tests pass locally (focused results are reported above).
  • Added regression tests for this change.
  • The PR is limited to this fix and its tests.
  • Numerical and public behaviour changes are stated above.
  • The contributor has personally read, run and understood the diff.
  • Required CI checks pass.

Prepared with ChatGPT (GPT-6 Astra Pro).

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.

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.

1 participant