Skip to content

Don't fail in step_info() if the rise-time level is never reached - #1259

Closed
syahra712 wants to merge 1 commit into
python-control:mainfrom
syahra712:step-info-rise-not-reached
Closed

syahra712 wants to merge 1 commit into
python-control:mainfrom
syahra712:step-info-rise-not-reached

Conversation

@syahra712

Copy link
Copy Markdown

step_info() raises IndexError when the response never reaches the rise-time limits within the time vector:

>>> import control as ct
>>> ct.step_info(ct.tf([2.99, -0.0685], [1, 2.83]))
IndexError: index 0 is out of bounds for axis 0 with size 0

This system is stable. The step response starts at 2.99, from the feedthrough, and decays to the DC gain of -0.0242. The default time vector ends at about 2.44 s, where the response is about -0.021. That is only about 87% of the final value, so np.nonzero(...)[0][0] for the 90% level is empty. The same error happens for time-series input whose yfinal is never approached, e.g. ct.step_info(1 - np.exp(-t), t, yfinal=1) with t in [0, 1].

Fix: if either rise-time level is never reached, RiseTime, SettlingMin and SettlingMax stay NaN. SettlingMin and SettlingMax are measured from the rise time onward. The other entries are computed as before. SettlingTime already falls back to NaN when the response doesn't settle. This follows the same idea as the fix for #1014.

Tests: added test_step_info_rise_not_reached to timeresp_test.py.

  • It covers time-series data and the transfer function above.
  • It fails without the fix with the IndexError, and passes with it.
  • Full control/tests result: 3858 passed, 554 skipped (no slycot).
  • ruff check is clean on the changed files.

AI-assisted (Claude): I used it to help read the code and draft the test. I reviewed and ran everything myself.

If the response never reaches the rise time limits (e.g. the default
time vector ends too early for a system with a large feedthrough
transient), np.nonzero(...)[0][0] raised IndexError.  Leave RiseTime,
SettlingMin and SettlingMax as NaN in that case.
@slivingston

Copy link
Copy Markdown
Member

@syahra712 Can you open an issue first, reporting the supposed bug that you are fixing?

@slivingston

Copy link
Copy Markdown
Member

@syahra712 Also, can you verify whether this PR was opened automatically by an AI agent?

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