Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
murrayrm merged 5 commits intopython-control:masterfrommurrayrm:standardize_squeeze
Jan 19, 2021

Conversation

murrayrm
Copy link
Member

@murrayrmmurrayrm commentedJan 14, 2021
edited
Loading

This PR addresses issue#453 by implementing a uniform method for handling thesqueeze keyword 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:

  • A new global defaultcontrol.squeeze_frequency_response that sets the default value for the squeeze keyword (set toNone initially).
  • Passing a set of frequencies (or complex values) that is not a scalar of a 1D array_like generates aValueError exception.
  • Updated docstrings
  • Unit tests to make sure that all of the various cases forsqueeze are correct.
  • Some minor PEP8 cleanup along the way

@murrayrmmurrayrm linked an issueJan 14, 2021 that may beclosed by this pull request
@coveralls
Copy link

coveralls commentedJan 14, 2021
edited
Loading

Coverage Status

Coverage increased (+0.03%) to 87.544% when pullingb338e32 on murrayrm:standardize_squeeze intob47ed08 on python-control:master.

Copy link
Contributor

@bnavigatorbnavigator left a 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)

@bnavigator
Copy link
Contributor

https://github.com/python-control/python-control/pull/507/checks?check_run_id=1703414743#step:5:75

control/tests/timeresp_test.py: 18 warnings  /home/runner/work/python-control/python-control/control/statesp.py:1506: UserWarning: Converting MIMO system to SIMO system. Only input 0 is used.    warn("Converting MIMO system to SIMO system. "

Better use pytest.warns to keep the warnings clean.

@murrayrmmurrayrm changed the titleStandardize squeeze and return_x in time/frequency response functionsStandardize squeeze processing in time/frequency response functionsJan 17, 2021
@murrayrmmurrayrm marked this pull request as draftJanuary 17, 2021 00:49
@murrayrm
Copy link
MemberAuthor

murrayrm commentedJan 17, 2021
edited
Loading

I've pulled out the time response portion of this PR and submitted it separately in#511. Converting this to a draft for now. See discussion in issue#453.

@murrayrmmurrayrm changed the titleStandardize squeeze processing in time/frequency response functionsStandardize squeeze processing in frequency response functionsJan 17, 2021
@murrayrmmurrayrm marked this pull request as ready for reviewJanuary 17, 2021 20:39
@@ -423,9 +440,14 @@ def __call__(self, s, squeeze=True):
:class:`FrequencyDomainData` systems are only defined at imaginary
frequency values.
"""
# Make sure that we are operating on a simple list
if len(np.array(s, ndmin=1).shape) > 1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
iflen(np.array(s,ndmin=1).shape)>1:
iflen(np.atleast1d(s).shape)>1:

# Make sure that we are operating on a simple list
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):
Copy link
Contributor

@sawyerbfullersawyerbfullerJan 18, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
ifany(abs(np.array(s,ndmin=1).real)>0):
ifany(abs(np.atleast1d(s).real)>0):

`m = self.inputs` number of inputs and `p = self.outputs` number of
outputs.

In general the system may be multiple input, multiple output
Copy link
Contributor

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
Copy link
Contributor

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’

Copy link
MemberAuthor

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, theLTI class does not show up, so the documentation appears in the StateSpace and TransferFunction classes. Leaving unchanged.

sawyerbfuller reacted with thumbs up emoji
@murrayrmmurrayrm merged commit6f674cf intopython-control:masterJan 19, 2021
@murrayrmmurrayrm deleted the standardize_squeeze branchJanuary 19, 2021 16:53
@murrayrmmurrayrm added this to the0.9.0 milestoneMar 20, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@bnavigatorbnavigatorbnavigator left review comments

@sawyerbfullersawyerbfullersawyerbfuller left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.9.0
Development

Successfully merging this pull request may close these issues.

proposal to standardize squeezing output from systems
4 participants
@murrayrm@coveralls@bnavigator@sawyerbfuller

[8]ページ先頭

©2009-2025 Movatter.jp