Skip to content

_remove_useless_states() can change types to ndarrays #82

Description

@manuelli

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'>

Activity

  1. roryyorke commented on Aug 12, 2016

    @roryyorke
    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'>
    
  2. slivingston commented on Aug 14, 2016

    @slivingston
    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))
    .

  3. roryyorke commented on Jan 1, 2017

    @roryyorke
    Contributor

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

  4. slivingston commented on Jan 1, 2017

    @slivingston
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions