fix(timeresp): avoid warning for discrete -1 poles#1225
Closed
marko1olo wants to merge 1 commit into
Closed
Conversation
Treat negative real discrete poles on the unit circle as oscillatory modes instead of decaying negative real modes, avoiding a divide-by-zero RuntimeWarning when computing the default impulse-response horizon. Co-authored-by: OpenAI Codex <codex@openai.com>
Member
|
@marko1olo There is already an open PR that is supposed to fix #1204 : #1216 I will re-open this PR if the other one is not sufficient. |
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.
Fixes #1204.
_ideal_tfinal_and_dt()already treats negative real discrete poles separately, but a pole exactly on the unit circle at-1was still sent through the decaying negative-real path. That path divides byreal(log(pole)), which is zero for-1, soimpulse_response()emitted aRuntimeWarningeven though the response itself was valid.This change keeps decaying negative real poles such as
-0.5on the existing decay-based path, keeps positive real discrete poles on the existing padded path, and lets unit-circle negative real poles flow to the pure oscillatory-mode estimate.Verification:
warnings.simplefilter("error", RuntimeWarning)before the fix.python -m pytest control\tests\timeresp_test.py::TestTimeresp::test_auto_generated_time_vector_tfinal control\tests\timeresp_test.py::TestTimeresp::test_discrete_negative_real_pole_tfinal control\tests\timeresp_test.py::TestTimeresp::test_discrete_time_impulse_negative_poles_no_warning -qpython -m pytest control\tests\timeresp_test.py -qpython -m ruff check --no-cache control\timeresp.py control\tests\timeresp_test.pyPYTHONPYCACHEPREFIX=C:\tmp\pycache-python-control-1204 python -m compileall -q control\timeresp.py control\tests\timeresp_test.pygit diff --checkAI-assisted contribution: implemented with OpenAI Codex and manually verified with the commands above.