Skip to content

Fix scalar feedback for square MIMO state-space systems#1232

Open
marko1olo wants to merge 1 commit into
python-control:mainfrom
marko1olo:fix-mimo-default-feedback
Open

Fix scalar feedback for square MIMO state-space systems#1232
marko1olo wants to merge 1 commit into
python-control:mainfrom
marko1olo:fix-mimo-default-feedback

Conversation

@marko1olo

Copy link
Copy Markdown
Contributor

Summary

Fix feedback(sys) / feedback(sys, scalar) for square MIMO StateSpace systems by treating scalar feedback as scalar * I with the system input/output size.

Before this change, the default sys2=1 was converted to a 1x1 static state-space system, so square MIMO systems failed the feedback dimension check even though explicit identity feedback worked.

Rectangular MIMO systems keep the existing incompatible-dimensions error.

Checks

  • Red repro before fix: ct.feedback(ct.ss([], [], [], [[1, 0], [0, 2]])) failed with ValueError: State space systems don't have compatible inputs/outputs for feedback.
  • Red repro before fix: ct.feedback(ct.rss(2, 2, 2)) failed with the same dimension error.
  • Post-fix smoke confirmed default square MIMO feedback matches explicit np.eye(n) feedback for static and dynamic systems.
  • python -m pytest control/tests/bdalg_test.py::TestFeedback::test_mimo_ss_scalar_feedback -q passed: 1 passed.
  • python -m pytest control/tests/bdalg_test.py control/tests/statesp_test.py control/tests/type_conversion_test.py -q passed: 1226 passed, 112 skipped, 1 xfailed, 1 warning.
  • python -m ruff check control/statesp.py control/tests/bdalg_test.py passed.
  • python -m compileall -q control/statesp.py control/tests/bdalg_test.py passed.
  • git diff --check HEAD~1..HEAD passed.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.746% (+0.01%) from 94.736% — marko1olo:fix-mimo-default-feedback into python-control:main

@marko1olo

marko1olo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Local verification on this branch:

python -m pytest control/tests/bdalg_test.py -q
49 passed

python -m pytest control/tests/statesp_test.py -q
828 passed, 112 skipped, 1 xfailed

python -m ruff check control/statesp.py control/tests/bdalg_test.py
All checks passed

git diff --check origin/main..HEAD
passed

The only local warning was pytest being unable to write .pytest_cache in this Windows worktree; the tests themselves passed.

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