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

_remove_useless_states() can change types to ndarrays #82

Closed
manuelli opened this issue Apr 7, 2016 · 4 comments
Closed

_remove_useless_states() can change types to ndarrays #82

manuelli opened this issue Apr 7, 2016 · 4 comments

Comments

@manuelli
Copy link

manuelli commented Apr 7, 2016

It seems that if you enter the if statement here then it replaces self.A withself.A with zeros(1,1) which is of type ndarray. This will cause problems later as the library is taking advantage of the fact that * is matrix multiplication not elementwise multiplcation as it would be for ndarrays.

Here is an example of the problem

sys1 = control.StateSpace(0,0,0,0)
sys2 = control.StateSpace(1,0,0,0)
print "type(sys1.A)", type(sys1.A)
print "type(sys2.A)", type(sys2.A)


type(sys1.A) <type 'numpy.ndarray'>
type(sys2.A) <class 'numpy.matrixlib.defmatrix.matrix'>
@roryyorke
Copy link
Contributor

Fixed in #107 (and it's follow-on, #108); above sample now gives

type(sys1.A) <class 'numpy.matrixlib.defmatrix.matrix'>
type(sys2.A) <class 'numpy.matrixlib.defmatrix.matrix'>

@slivingston
Copy link
Member

The link to the source code given in the opening post is floating (i.e., it tracks the tip of master branch). For posterity, a link that is fixed with respect to the current master is

if all(useless == range(self.states)):
# All the states were useless.
self.A = zeros((1, 1))
self.B = zeros((1, self.inputs))
self.C = zeros((self.outputs, 1))
.

@roryyorke
Copy link
Contributor

Bug not present in d8b07cb; most likely fixed by #110, which superseded #107 and #108.

@slivingston
Copy link
Member

Yes, I agree that it is fixed. I just ran the example from the opening post using the current tip of master branch (32f13bc), and the output is

type(sys1.A) <class 'numpy.matrixlib.defmatrix.matrix'>
type(sys2.A) <class 'numpy.matrixlib.defmatrix.matrix'>

as reported earlier in #82 (comment).

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

No branches or pull requests

3 participants