Repository navigation
fix(trajectory): trapezoidal_func gives scalars for a scalar time, and is an object - #808
Merged
Merged
Conversation
…Traj validates traj Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d is an object A scalar time gave arrays with one element from trapezoidal_func and scalars from quintic_func, and the Cartesian block had both in the one variable. The profile is now a TrapezoidalProfile, called as before, with the attributes tb and V declared instead of attached to a function, which also removes the Protocol and the cast. Traj validates traj at construction, rather than failing with an UnboundLocalError in start(), and calls the two builders explicitly. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
| Duplication | 0 |
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
added a commit
that referenced
this pull request
Oct 16, 2026
* chore(typing): annotate tools/trajectory.py
Remove the module from the mypy ignore list and annotate it. mypy found
real faults that the missing annotations had hidden:
- Trajectory.qplot called xplot, which was never imported: NameError.
- jtraj documented array_like for the time but only accepted an ndarray.
- the verbose message in mstraj had a non-f-string with {slowest}.
- Trajectory.qd and qdd returned None when the trajectory had no data; they
now raise ValueError, as the return type is an array.
trapezoidal_func returns a TrapezoidalFunc, a Protocol that says the function
has the attributes tb and V. tblend, arrive, info and via, set by trapezoidal
and mstraj, are declared on Trajectory.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* fix(trajectory): trapezoidal_func gives scalars for a scalar time, and is an object (#808)
* test(trajectory): scalar time gives scalars, trapezoid is an object, Traj validates traj
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* test(trajectory): import TrapezoidalProfile inside its test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* fix(trajectory): trapezoidal_func gives scalars for a scalar time, and is an object
A scalar time gave arrays with one element from trapezoidal_func and scalars
from quintic_func, and the Cartesian block had both in the one variable. The
profile is now a TrapezoidalProfile, called as before, with the attributes tb
and V declared instead of attached to a function, which also removes the
Protocol and the cast.
Traj validates traj at construction, rather than failing with an
UnboundLocalError in start(), and calls the two builders explicitly.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docs(blocks): versionchanged notes for the Trapezoidal and Traj blocks
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.
Summary
Stacked on #807 (the base of this PR is its branch, so the diff is only the three commits here; it is retargeted to
mainwhen #807 merges).A scalar time gave arrays with one element from
trapezoidal_funcand scalars fromquintic_func, and a 2-D array of times raised an error. The Cartesian block even had both shapes in one variable (s = self.trapezoidalfunc(t)[0]againsts = min(t / self.T, 1.0)).trapezoidal_func(q0, qf, T, V)has the same name and arguments but returns aTrapezoidalProfile, an object that is called in the same way, withtbandVas declared attributes rather than attributes attached to a function. The Protocol and thecastfrom chore(typing): annotate tools/trajectory.py #807 go.Trajblock validatestrajat construction (it failed with anUnboundLocalErrorwhen the simulation started) and calls the two builders explicitly, so they no longer have to look alike.Behaviour change
The bdsim
Trapezoidalblock output three arrays with one element each per step, and now outputs three scalars, which is what its port table says (float). TheTrajblock output is unchanged. Both docstrings carry aversionchangednote.The book uses
quintic,trapezoidal,mtraj,jtrajandmstraj, not the_funcversions, so no errata.Tests
tests/test_trapezoidal_profile.py, written first: 4 of 11 failed on the base (scalar shape, 2-D shape, the object,Trajvalidation), then all pass. Full suite: same 29 failures asmainhere (stale compiled extension); mypy clean on 164 files.Related issue
Follows #807 and #805.
🤖 Generated with Claude Code