Skip to content

Fix namespace and logic errrors in statesp.freqresp + unit tests#196

Merged
murrayrm merged 3 commits intopython-control:masterfrom
murrayrm:fix_ss_fresp_dtime
Jul 2, 2018
Merged

Fix namespace and logic errrors in statesp.freqresp + unit tests#196
murrayrm merged 3 commits intopython-control:masterfrom
murrayrm:fix_ss_fresp_dtime

Conversation

@murrayrm
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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 frequency")
warnings.warn(warn_message)
if (max(omega) * dt > math.pi):
Copy link
Copy Markdown
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
Copy Markdown
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