GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Allow np.array or np.matrix for state space matrices, operations by murrayrm · Pull Request #314 · python-control/python-control Conversation
Member
This PR addresses issue #233 regarding (eventual) deprecation of the For backward compatibility, the A set of unit tests is also included for testing basic operations when the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Coverage increased (+0.06%) to 82.173% when pulling 7c9d9a6 on murrayrm:ss_matrix into e2346cd on python-control:master. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| >>> sys2 = ss([[-1.]], [[1.]], [[1.]], [[0.]]) | ||
| >>> sys = append(sys1, sys2) | ||
| >>> Q = sp.mat([ [ 1, 2], [2, -1] ]) # basically feedback, output 2 in 1 | ||
| >>> Q = [[1, 2], [2, -1]]) # negative feedback interconnection |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
trailing parenthesis here looks wrong. Do we run these with doctest?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
We are not currently using doctest, but I ran the revised version manually to make sure it was OK.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| eye(self.inputs)) | ||
| eye(self.inputs) | ||
| + np.dot(other.fresp[:, :, k], self.fresp[:, :, k]), | ||
| eye(self.inputs)) |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I know this is not the point of this change, but is linalg(X, eye(shape)) any better than np.linalg.inv? I'd have thought a "right divide" (linalg.solve with appropriate transposes) would have been a more standard approach.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I agree that this could use sp.linalg.solve instead, but since I wasn't the original author I just did the conversion to remove the np.matrix dependence. I've added a TODO for someone to fix this, so at least we don't forget about it (in principle).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| """ | ||
|
|
||
| from scipy import shape, size, asarray, asmatrix, copy, zeros, eye, dot | ||
| from scipy import shape, size, array, asarray, copy, zeros, eye, dot |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
again not the point, but since you remove import scipy as sp, I think this should be from numpy import ...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| where Q is a symmetric matrix and A, Q and E are square matrices | ||
| of the same dimension. """ | ||
| of the same dimension. | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not super-familiar with PEP8 and so on, but this extra blank line seems odd.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The extra blank line is a numpydoc standard: https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Place the poles using Ackermann's method | ||
| n = np.size(p) | ||
| pmat = p[n-1]*a**0 | ||
| pmat = p[n-1] * np.linalg.matrix_power(a, 0) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
np.eye(a.shape) ? I suppose the matrix_power call sets the stage for the upcoming for-loop.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| pmat = p[n-1] * np.linalg.matrix_power(a, 0) | ||
| for i in np.arange(1,n): | ||
| pmat = pmat + p[n-i-1]*a**i | ||
| pmat = pmat + np.dot(p[n-i-1], np.linalg.matrix_power(a, i)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Again somewhat beside the point of this commit, but would it be possible to use Horner's method here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO for someone to do this in a separate PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
CI tests are failing due to issue #321. Need to fix before merging. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.