-
Notifications
You must be signed in to change notification settings - Fork 438
Allow static gain StateSpace objects to be straightforwardly created. #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ects. Allows StateSpace([],[],[],D), which failed previously. Static gains have sizes enforced as follows: A 0-by-0, B 0-by-ninputs, C noutputs-by-0. Tests added for instantiation, and sum, product, feedback, and appending, of 1x1, 2x3, and 3x2 static gains StateSpace objects.
On Python 2.7, the special case "all states useless" in _remove_useless_states resulted in A=[[0]] (and similarly for B and C). The special case is no longer needed, since empty A, B, C matrices can be handled. numpy.delete does the right thing w.r.t. matrix sizes (e.g., deleting all columns of a nxm matrix gives an nx0 matrix). Added test for this.
raise ValueError("D must have the same column size as B.") | ||
if self.outputs != D.shape[0]: | ||
raise ValueError("D must have the same row size as C.") | ||
raise ValueError("A and C C must have the same number of columns.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's one C
too many here. 😸
D'oh! Thanks, will fix. |
I like this syntax for creating static gain objects. This PR looks good to me. |
One case not covered by this PR is the "empty" system, Wanting 0-input, 0-output systems may seem like fussiness, but it turns out to be necessary (or useful, at least), in a prototype of [1] http://octave.sourceforge.net/control/function/augw.html |
Conflicts: control/tests/statesp_test.py
Pull request #110 subsumes this one. |
Lets the (fairly?) obvious StateSpace([],[],[],D) work. One could previously create these by, e.g., converting a static gain TransferFunction to a StateSpace object.
In this case A will be 0-by-0, B 0-by-inputs, and C outputs-by-0. My intuition is that this is a generally correct approach (consider the simplification of _remove_useless_states, for example), but it may require some thought during review.