-
Notifications
You must be signed in to change notification settings - Fork 441
Fix namespace and logic errrors in statesp.freqresp + unit tests #196
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
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
bode(sys, omega_ok) | ||
|
||
else: | ||
# Calling bode should generate a not implemented error |
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.
how about self.assertRaises(NotImplementedError, bode, (sys,))
?
control/statesp.py
Outdated
warn_message = ("evalfr: frequency evaluation" | ||
" above Nyquist freque 8000 ncy") | ||
warnings.warn(warn_message) | ||
if (max(omega) * dt > math.pi): |
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.
perhaps max(abs(omega))
, to allow for negative omega?
nitpick: outermost parentheses are unnecessary.
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 |
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.
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.
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.