Fix stepinfo crash when response does not reach risetime thresholds#1059
Merged
Conversation
`stepinfo` indexed `res.t[i10]` / `res.t[i90]` without checking that `findfirst` actually located the rise-time crossings. For a response that never crosses the lower or upper threshold within the simulation window, `findfirst` returns `nothing` and the indexing then raised `MethodError: no method matching getindex(..., ::Nothing)`. The function now sets `i10`/`i90` to `0` (sentinel for "not reached"), sets `risetime = NaN`, and emits a warning. The `stepinfoplot` recipe skips the rise-time series when either index is zero. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This is an automated message.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1059 +/- ##
==========================================
- Coverage 91.61% 91.55% -0.07%
==========================================
Files 42 42
Lines 5653 5659 +6
==========================================
+ Hits 5179 5181 +2
- Misses 474 478 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
stepinfoindexedres.t[i10]/res.t[i90]without checking whetherfindfirstactually found the rise-time crossings. When the response never reaches the lower or upper threshold within the simulation window,findfirstreturnsnothingand the subsequent indexing crashes withMethodError.This PR:
i10/i90to0(sentinel meaning "not reached") andrisetime = NaNwhen either threshold is not crossed, plus emits a warning.stepinfoplotrecipe to skip the rise-time series when either index is zero (so the plot still renders).Test plan
stepinfo(step(tf(1,[1,0,1]), 5))(an oscillator that doesn't settle, with too-short horizon) no longer throws.plot(stepinfo(...))on the same input renders without error.test_timeresp.jlstill passes.🤖 Generated with Claude Code