-
Notifications
You must be signed in to change notification settings - Fork 441
Cover more of root_locus: dtime and sisotool #617
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,16 +15,25 @@ | |
from control.bdalg import feedback | ||
|
||
|
||
@pytest.mark.usefixtures("mplcleanup") | ||
class TestRootLocus: | ||
"""These are tests for the feedback function in rlocus.py.""" | ||
|
||
@pytest.fixture(params=[(TransferFunction, ([1, 2], [1, 2, 3])), | ||
(StateSpace, ([[1., 4.], [3., 2.]], | ||
[[1.], [-4.]], | ||
[[1., 0.]], [[0.]]))], | ||
ids=["tf", "ss"]) | ||
@pytest.fixture(params=[pytest.param((sysclass, sargs + (dt, )), | ||
id=f"{systypename}-{dtstring}") | ||
for sysclass, systypename, sargs in [ | ||
(TransferFunction, 'TF', ([1, 2], | ||
[1, 2, 3])), | ||
(StateSpace, 'SS', ([[1., 4.], [3., 2.]], | ||
[[1.], [-4.]], | ||
[[1., 0.]], | ||
[[0.]])), | ||
] | ||
for dt, dtstring in [(0, 'ctime'), | ||
(True, 'dtime')] | ||
]) | ||
def sys(self, request): | ||
"""Return some simple LTI system for testing""" | ||
"""Return some simple LTI systems for testing""" | ||
# avoid construction during collection time: prevent unfiltered | ||
# deprecation warning | ||
sysfn, args = request.param | ||
|
@@ -37,7 +46,7 @@ def check_cl_poles(self, sys, pole_list, k_list): | |
np.testing.assert_array_almost_equal(poles, poles_expected) | ||
|
||
def testRootLocus(self, sys): | ||
"""Basic root locus plot""" | ||
"""Basic root locus (no plot)""" | ||
klist = [-1, 0, 1] | ||
|
||
roots, k_out = root_locus(sys, klist, plot=False) | ||
|
@@ -49,6 +58,33 @@ def test_without_gains(self, sys): | |
roots, kvect = root_locus(sys, plot=False) | ||
self.check_cl_poles(sys, roots, kvect) | ||
|
||
@pytest.mark.parametrize('grid', [None, True, False]) | ||
def test_root_locus_plot_grid(self, sys, grid): | ||
rlist, klist = root_locus(sys, grid=grid) | ||
ax = plt.gca() | ||
n_gridlines = sum([int(line.get_linestyle() in [':', 'dotted', | ||
'--', 'dashed']) | ||
for line in ax.lines]) | ||
if grid is False: | ||
assert n_gridlines == 2 | ||
else: | ||
assert n_gridlines > 2 | ||
# TODO check validity of grid | ||
|
||
def test_root_locus_warnings(self): | ||
sys = TransferFunction([1000], [1, 25, 100, 0]) | ||
with pytest.warns(FutureWarning, match="Plot.*deprecated"): | ||
rlist, klist = root_locus(sys, Plot=True) | ||
with pytest.warns(FutureWarning, match="PrintGain.*deprecated"): | ||
rlist, klist = root_locus(sys, PrintGain=True) | ||
|
||
def test_root_locus_neg_false_gain_nonproper(self): | ||
""" Non proper TranferFunction with negative gain: Not implemented""" | ||
with pytest.raises(ValueError, match="with equal order"): | ||
root_locus(TransferFunction([-1, 2], [1, 2])) | ||
|
||
# TODO: cover and validate negative false_gain branch in _default_gains() | ||
|
||
def test_root_locus_zoom(self): | ||
"""Check the zooming functionality of the Root locus plot""" | ||
system = TransferFunction([1000], [1, 25, 100, 0]) | ||
|
@@ -96,4 +132,3 @@ def test_rlocus_default_wn(self): | |
[-1e-2, 1-1e7j, 1+1e7j], [0, -1e7j, 1e7j], 1)) | ||
|
||
ct.root_locus(sys) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ universal=1 | |
addopts = -ra | ||
filterwarnings = | ||
error:.*matrix subclass:PendingDeprecationWarning | ||
|
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.
You can’t perform that action at this time.
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.
Any idea why there are two different sgrid functions? there is this one and there is grid.sgrid. Maybe a different PR, but would be good to unify these and get the best of each of them.
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.
Apparently _sgrid_func() was removed in #193 but reintroduced through some merge gone wrong?
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.
908fabe