8000 Fix namespace and logic errrors in statesp.freqresp + unit tests by murrayrm · Pull Request #196 · python-control/python-control · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 3 commits into from
Jul 2, 2018

Conversation

murrayrm
Copy link
Member

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.

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.
@murrayrm murrayrm added this to the 0.8.0 milestone Feb 24, 2018
@coveralls
Copy link
coveralls commented Feb 24, 2018

Coverage Status

Coverage increased (+1.08%) to 78.962% when pulling f2af185 on murrayrm:fix_ss_fresp_dtime into 601b581 on python-control:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 78.328% when pulling 057c5ca on murrayrm:fix_ss_fresp_dtime into 601b581 on python-control:master.

Python 2.7 represses repeated warnings in a way that causes the unit test
to fail => make sure that warnings are always generated
@murrayrm murrayrm mentioned this pull request Mar 11, 2018
bode(sys, omega_ok)

else:
# Calling bode should generate a not implemented error
Copy link
Contributor

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,)) ?

warn_message = ("evalfr: frequency evaluation"
" above Nyquist freque 8000 ncy")
warnings.warn(warn_message)
if (max(omega) * dt > math.pi):
Copy link
Contributor

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.

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

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.

@murrayrm murrayrm merged commit 26661f6 into python-control:master Jul 2, 2018
@murrayrm murrayrm deleted the fix_ss_fresp_dtime branch July 2, 2018 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0