Fix namespace and logic errrors in statesp.freqresp + unit tests#196
Merged
murrayrm merged 3 commits intopython-control:masterfrom Jul 2, 2018
Merged
Fix namespace and logic errrors in statesp.freqresp + unit tests#196murrayrm merged 3 commits intopython-control:masterfrom
murrayrm merged 3 commits intopython-control:masterfrom
Conversation
As pointed out in PR python-control#192, there were some namespace errors in the statesp module related to checking whether the frequency range as valid for discrete time systems. I added a unit test that covered this code (and exposed the error) and fixed up the namespace problems (as in PR python-control#192). There was also a logic error in the way that frequencies were checked and the warning message referred to the wrong function.
Python 2.7 represses repeated warnings in a way that causes the unit test to fail => make sure that warnings are always generated
Closed
roryyorke
reviewed
Mar 13, 2018
| bode(sys, omega_ok) | ||
|
|
||
| else: | ||
| # Calling bode should generate a not implemented error |
Contributor
There was a problem hiding this comment.
how about self.assertRaises(NotImplementedError, bode, (sys,)) ?
roryyorke
reviewed
Mar 13, 2018
control/statesp.py
Outdated
| warn_message = ("evalfr: frequency evaluation" | ||
| " above Nyquist frequency") | ||
| warnings.warn(warn_message) | ||
| if (max(omega) * dt > math.pi): |
Contributor
There was a problem hiding this comment.
perhaps max(abs(omega)), to allow for negative omega?
nitpick: outermost parentheses are unnecessary.
roryyorke
reviewed
Mar 13, 2018
control/tests/freqresp_test.py
Outdated
| omega_bad = np.linspace(10e-4,1.1,10) * np.pi/sys.dt | ||
| ret = sys.freqresp(omega_bad) | ||
| print("len(w) =", len(w)) | ||
| assert len(w) == 1 |
Contributor
There was a problem hiding this comment.
I see this is based on the example from the warnings module docs, but perhaps changing the bare asserts to self.assertEqual and self.assertIn would be good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As pointed out in PR #192, there were some namespace errors in the statesp
module related to checking whether the frequency range as valid for discrete
time systems. I added a unit test that covered this code (and exposed the
error) and fixed up the namespace problems (as in PR #192). There was also
a logic error in the way that frequencies were checked and the warning message
referred to the wrong function.