Preserve complex StateSpace matrices#1230
Open
marko1olo wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Local verification on The only local warning was pytest being unable to write |
Member
|
@marko1olo thanks for this and the other recent PRs that you have opened. I have several requests that apply to all of these (including this one):
|
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 #1058.
StateSpace(A, B, C, D)currently coerces every state-space matrix throughnp.array(..., dtype=float), which silently discards imaginary parts from complex-valued matrices and emitsComplexWarning. State-space operations already evaluate complex frequencies and NumPy can safely keep real matrices as floats, so this changes_ssmatrix()to preserve complex dtype only when the input is complex-valued.The regression test covers complex A/B/C/D matrices and treats constructor warnings as errors, so the old
ComplexWarningpath fails directly.Validation:
mainbefore the fix: complex matrices were stored as real matrices and emitted fourComplexWarnings.python -m pytest control/tests/statesp_test.py::TestStateSpace::test_constructor_complex_matrices control/tests/statesp_test.py::TestStateSpace::test_constructor_invalid -qpython -m pytest control/tests/statesp_test.py -qpython -m pytest control/tests/convert_test.py control/tests/type_conversion_test.py control/tests/xferfcn_test.py control/tests/bdalg_test.py -qpython -m ruff check control/statesp.py control/tests/statesp_test.pypython -m compileall -q controlgit diff --checkNote: I also attempted
python -m pytest control/tests -q, but the local Windows run exceeded a 5-minute timeout before producing useful output.Assisted-by: OpenAI Codex