GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Nyquist plot improvements by murrayrm · Pull Request #534 · python-control/python-control Conversation
Member
This PR provides improvements to Nyquist plots:
Other notes:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Coverage increased (+0.5%) to 88.798% when pulling e0521b9 on murrayrm:improve_nyquist into eb62d80 on python-control:master. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| # If argument was a singleton, turn it into a list | ||
| if not hasattr(syslist, '__iter__'): | ||
| isscalar = not hasattr(syslist, '__iter__') |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
IsScalar sounds like it could be referring to the system. ‘Is_Single_system’?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| from ..freqplot import nyquist_plot | ||
|
|
||
| # If first argument is a list, assume python-control calling format | ||
| if (getattr(args[0], '__iter__', False)): |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I have seen this style elsewhere in the library so I am curious: isn’t hasattr(args[0], ‘ iter’) both more readable and compact? (I can’t do backticks from my phone so underscores appear as bold)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
hasattr also returns True if args[0] is an iterable sequence, but empty. This code only branches if args[0] is iterable and the sequence does not cast to False (is empty).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
getattr([], '__iter__', False) returns <method-wrapper '__iter__' of list object .... So looks like both of them would follow the branch?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Very nice! Plots look great and I think the new return values make sense. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @pytest.fixture(scope="function") | ||
| def figure_cleanup(): | ||
| plt.close('all') | ||
| yield | ||
| plt.close('all') |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Did you try to use the existing mplcleanup (automatically loaded from conftest.py)?
python-control/control/tests/conftest.py
Lines 111 to 124 in d75c395
| @pytest.fixture(scope="function") | |
| def mplcleanup(): | |
| """Workaround for python2 | |
| python 2 does not like to mix the original mpl decorator with pytest | |
| fixtures. So we roll our own. | |
| """ | |
| save = mpl.units.registry.copy() | |
| try: | |
| yield | |
| finally: | |
| mpl.units.registry.clear() | |
| mpl.units.registry.update(save) | |
| mpl.pyplot.close("all") |
Now that we don't test python2 anymore, we could directly map it to matplotlib.testing.decorators.cleanup
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d311109 to
dda3149
Compare
|
Hmm, I wonder why the nichols_test xlim warning is back here. The test is run before nyquist test and already uses the mplcleanup fixture. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* regularize argument parsing by using _parse_freqplot_args * fix bug in exception handling (ControlArgument not defined) * change printed warning to use warnings.warn * add unit tests for exceptions, warnings
* start tracing from omega = 0 * add support for indenting around imaginary poles * change return value to number of encirclements (+ contour, if desired) * update MATLAB interface to retain legacy format * new unit tests
dda3149 to
e0521b9
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
arrows in nyquist plot
There was an error while loading. Please reload this page.