8000 Time response plots by murrayrm · Pull Request #920 · python-control/python-control · GitHub
[go: up one dir, main page]

Skip to content

Time response plots #920

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 12 commits into from
Jul 13, 2023
Merged
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
from .xferfcn import *
from .frdata import *

# Time responses and plotting
from .timeresp import *
from .timeplot import *

from .bdalg import *
from .delay import *
from .descfcn import *
Expand All @@ -91,7 +95,6 @@
from .rlocus import *
from .statefbk import *
from .stochsys import *
from .timeresp import *
from .ctrlutil import *
from .canonical import *
from .robust import *
Expand Down
3 changes: 3 additions & 0 deletions control/config.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def reset_defaults():
from .optimal import _optimal_defaults
defaults.update(_optimal_defaults)

from .timeplot import _timeplot_defaults
defaults.update(_timeplot_defaults)


def _get_param(module, param, argval=None, defval=None, pop=False, last=False):
"""Return the default value for a configuration option.
Expand Down
4 changes: 3 additions & 1 deletion control/nlsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ def ufun(t):
return TimeResponseData(
t_eval, y, None, u, issiso=sys.issiso(),
output_labels=sys.output_labels, input_labels=sys.input_labels,
title="Input/output response for " + sys.name, sysname=sys.name,
transpose=transpose, return_x=return_x, squeeze=squeeze)

# Create a lambda function for the right hand side
Expand Down Expand Up @@ -1567,7 +1568,8 @@ def ivp_rhs(t, x):
return TimeResponseData(
soln.t, y, soln.y, u, issiso=sys.issiso(),
output_labels=sys.output_labels, input_labels=sys.input_labels,
state_labels=sys.state_labels,
state_labels=sys.state_labels, sysname=sys.name,
title="Input/output response for " + sys.name,
transpose=transpose, return_x=return_x, squeeze=squeeze)


Expand Down
20 changes: 19 additions & 1 deletion control/tests/kwargs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import control.tests.statefbk_test as statefbk_test
import control.tests.stochsys_test as stochsys_test
import control.tests.trdata_test as trdata_test
import control.tests.timeplot_test as timeplot_test

@pytest.mark.parametrize("module, prefix", [
(control, ""), (control.flatsys, "flatsys."), (control.optimal, "optimal.")
Expand Down Expand Up @@ -74,7 +75,8 @@ def test_kwarg_search(module, prefix):
# @parametrize messes up the check, but we know it is there
pass

elif source and source.find('unrecognized keyword') < 0:
elif source and source.find('unrecognized keyword') < 0 and \
source.find('unexpected keyword') < 0:
warnings.warn(
f"'unrecognized keyword' not found in unit test "
f"for {name}")
Expand Down Expand Up @@ -161,7 +163,21 @@ def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
function(*args, **kwargs, unknown=None)


@pytest.mark.parametrize(
"function", [control.time_response_plot, control.TimeResponseData.plot])
def test_time_response_plot_kwargs(function):
# Create a system for testing
response = control.step_response(control.rss(4, 2, 2))

# Call the plotting function normally and make sure it works
function(response)

# Now add an unrecognized keyword and make sure there is an error
with pytest.raises(AttributeError,
match="(has no property|unexpected keyword)"):
function(response, unknown=None)


#
# List of all unit tests that check for unrecognized keywords
#
Expand All @@ -185,6 +201,7 @@ def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
'gangof4_plot': test_matplotlib_kwargs,
'input_output_response': test_unrecognized_kwargs,
'interconnect': interconnect_test.test_interconnect_exceptions,
'time_response_plot': timeplot_test.test_errors,
'linearize': test_unrecognized_kwargs,
'lqe': test_unrecognized_kwargs,
'lqr': test_unrecognized_kwargs,
Expand Down Expand Up @@ -230,6 +247,7 @@ def test_matplotlib_kwargs(function, nsysargs, moreargs, kwargs, mplcleanup):
'StateSpace.__init__': test_unrecognized_kwargs,
'StateSpace.sample': test_unrecognized_kwargs,
'TimeResponseData.__call__': trdata_test.test_response_copy,
'TimeResponseData.plot': timeplot_test.test_errors,
'TransferFunction.__init__': test_unrecognized_kwargs,
'TransferFunction.sample': test_unrecognized_kwargs,
'optimal.OptimalControlProblem.__init__':
Expand Down
Loading
0