★ wanayoo — archive 1999 https://github.com/python-control/python-control/pull/107Nouvelle recherche | Portail wanayoo
Skip to content
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

Allow static gain StateSpace objects to be straightforwardly created. #107

Closed

Conversation

@roryyorke
Copy link
Contributor

@roryyorke roryyorke commented Aug 11, 2016

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.

roryyorke added 2 commits Aug 11, 2016
…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.
@coveralls
Copy link

@coveralls coveralls commented Aug 11, 2016 •

Coverage Status

Coverage increased (+0.04%) to 76.048% when pulling 7382644 on roryyorke:rory-ss-static-gain into d0528fd on python-control:master.

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.")

This comment has been minimized.

@mp4096

mp4096 Aug 12, 2016
Contributor

I think it's one C too many here. 😸

@roryyorke
Copy link
Contributor Author

@roryyorke roryyorke commented Aug 12, 2016

D'oh! Thanks, will fix.

@coveralls
Copy link

@coveralls coveralls commented Aug 12, 2016 •

Coverage Status

Coverage increased (+0.04%) to 76.048% when pulling 2794260 on roryyorke:rory-ss-static-gain into d0528fd on python-control:master.

@cwrowley
Copy link
Contributor

@cwrowley cwrowley commented Aug 29, 2016

I like this syntax for creating static gain objects. This PR looks good to me.

@roryyorke roryyorke mentioned this pull request Aug 31, 2016
@roryyorke
Copy link
Contributor Author

@roryyorke roryyorke commented Sep 18, 2016

One case not covered by this PR is the "empty" system, StateSpace([],[],[],[]). My first attempt at handling this broke StateSpace.__getitem__; I haven't yet come up with a tidy fix. The source of the hassle, IMO, is that numpy.matrix([]) returns a 1x0 matrix, rather than 0x0. My current thinking is to have a numpy.matrix wrapper, statesp._matrix, for which _matrix([] is 0x0.

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 augw I've written. (augw ends up being part of mixsyn; see Octave's docs for augw at [1]).

[1] http://octave.sourceforge.net/control/function/augw.html

Conflicts:
	control/tests/statesp_test.py
@coveralls
Copy link

@coveralls coveralls commented Dec 25, 2016 •

Coverage Status

Coverage decreased (-0.3%) to 75.714% when pulling e640b17 on roryyorke:rory-ss-static-gain into d0528fd on python-control:master.

@slivingston
Copy link
Member

@slivingston slivingston commented Dec 27, 2016

Pull request #110 subsumes this one.

@roryyorke roryyorke deleted the roryyorke:rory-ss-static-gain branch Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.