Skip to content

Fix stepinfo crash when response does not reach risetime thresholds#1059

Merged
baggepinnen merged 1 commit into
masterfrom
fix/stepinfo-nothing-risetime
May 16, 2026
Merged

Fix stepinfo crash when response does not reach risetime thresholds#1059
baggepinnen merged 1 commit into
masterfrom
fix/stepinfo-nothing-risetime

Conversation

@baggepinnen
Copy link
Copy Markdown
Member

Summary

stepinfo indexed res.t[i10]/res.t[i90] without checking whether findfirst actually found the rise-time crossings. When the response never reaches the lower or upper threshold within the simulation window, findfirst returns nothing and the subsequent indexing crashes with MethodError.

This PR:

  • Sets i10/i90 to 0 (sentinel meaning "not reached") and risetime = NaN when either threshold is not crossed, plus emits a warning.
  • Guards the stepinfoplot recipe 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.
  • Existing test_timeresp.jl still passes.

🤖 Generated with Claude Code

`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>
@JuliaControlBot
Copy link
Copy Markdown

This is an automated message.
Plots were compared to references. 4/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.55%. Comparing base (0aa6e4c) to head (99b5cef).

Files with missing lines Patch % Lines
lib/ControlSystemsBase/src/timeresp.jl 33.33% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@baggepinnen baggepinnen merged commit ec4afdc into master May 16, 2026
4 of 6 checks passed
@baggepinnen baggepinnen deleted the fix/stepinfo-nothing-risetime branch May 16, 2026 03:55
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