-
Notifications
You must be signed in to change notification settings - Fork 446
Standardize squeeze processing in frequency response functions #507
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
Conversation
bnavigator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(except for the commit sequence. make sure to rebase/squash before merge)
61bba31 to
a69a331
Compare
a69a331 to
4ec6377
Compare
|
https://github.com/python-control/python-control/pull/507/checks?check_run_id=1703414743#step:5:75 Better use pytest.warns to keep the warnings clean. |
b337c9c to
90da4fb
Compare
control/frdata.py
Outdated
| frequency values. | ||
| """ | ||
| # Make sure that we are operating on a simple list | ||
| if len(np.array(s, ndmin=1).shape) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if len(np.array(s, ndmin=1).shape) > 1: | |
| if len(np.atleast1d(s).shape) > 1: |
control/frdata.py
Outdated
| if len(np.array(s, ndmin=1).shape) > 1: | ||
| raise ValueError("input list must be 1D") | ||
|
|
||
| if any(abs(np.array(s, ndmin=1).real) > 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if any(abs(np.array(s, ndmin=1).real) > 0): | |
| if any(abs(np.atleast1d(s).real) > 0): |
control/statesp.py
Outdated
| `m = self.inputs` number of inputs and `p = self.outputs` number of | ||
| outputs. | ||
| In general the system may be multiple input, multiple output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably remove this paragraph. Was added to precisely specify return array size but now no longer needed
| squeeze is False, the array is 3D, indexed by the output, input, and | ||
| frequency. If ``squeeze`` is True then single-dimensional axes are | ||
| removed. | ||
| phase : ndarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ‘notes’ on line 575ish below, this function is actually a wrapper for :meth:’lti.frequency_response’
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the way the documentation is built, the LTI class does not show up, so the documentation appears in the StateSpace and TransferFunction classes. Leaving unchanged.
This PR addresses issue #453 by implementing a uniform method for handling the
squeezekeyword in frequency response functions (frequency_response,__call__, etc). This PR matches the changes in PR #511 to improve consistency between time and frequency response, as described in issue #453.The following behavior is implemented:
squeeze=None(default case): squeeze inputs and outputs, but leave frequencies alone. This is consistent with current behavior.squeeze=True: numpy squeeze => all singleton axes are removed, consistent with numpy.squeeze=False: full MIMO, even for SISO. You always get a p x m array for outputs versus inputs.Additional changes:
control.squeeze_frequency_responsethat sets the default value for the squeeze keyword (set toNoneinitially).ValueErrorexception.squeezeare correct.