Skip to content

doc inconsistency about return type of lqr - matrix vs array #418

Closed

Description

@jerabaul29

I think the doc about the return type of the lqr function looks inconsistent:

https://python-control.readthedocs.io/en/0.8.1/generated/control.lqr.html

states that K is a 2-d array. But it looks a lot like a matrix actually :)

>>> K, _, _ = control.lqr(np.array([1]), np.array([1]), np.array([1]), np.array([1]))
>>> K
matrix([[2.41421356]])

This is Python 3.6.9, control 0.8.3, Ubuntu 18.04 defaults.

This leads to possibly subtle bugs:

https://stackoverflow.com/questions/62342225/how-to-squeeze-when-numpy-squeeze-does-not-seem-to-squeeze?

Do you think it may be a good idea to 1) update the doc 2) maybe change from matrix to array output altogether? :)

Activity

  1. murrayrm commented on Jun 12, 2020

    @murrayrm
    Member

    The plan is to shift away from the use of the np.matrix class at a future point. This functionality is already in place through the use of the use_numpy_matrix function. In version 0.8.3, the np.matrix class is still used for backward compatibility, but you can switch to using arrays through the function call

    control.use_numpy_matrix(False)
    

    When we release version 0.9.0, we will switch to have np.ndarray be the default class for all matrices in python-control.

    I'll leave this issue open for a bit because I think we generally need to update the documentation to reflect that fact that the return type for functions depends on how you have configured python-control. I've been collecting up documentation updates, so will include those changes in that PR.

  2. self-assigned this
    on Jun 12, 2020
  3. added this to the 0.8.4 milestone on Jun 12, 2020
  4. linked a pull request that will close this issueDocumentation update #476on Dec 22, 2020
  5. added a commit that references this issue on Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions