Skip to content

Commit 34c2c7e

Browse files
committed
add kwarg checks + rebase cleanup
1 parent 051e196 commit 34c2c7e

4 files changed

Lines changed: 33 additions & 29 deletions

File tree

control/iosys.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,14 +1672,14 @@ def input_output_response(
16721672
raise ValueError("ivp_method specified more than once")
16731673
solve_ivp_kwargs['method'] = kwargs.pop('solve_ivp_method')
16741674

1675-
# Make sure there were no extraneous keywords
1676-
if kwargs:
1677-
raise TypeError("unrecognized keywords: ", str(kwargs))
1678-
16791675
# Set the default method to 'RK45'
16801676
if solve_ivp_kwargs.get('method', None) is None:
16811677
solve_ivp_kwargs['method'] = 'RK45'
16821678

1679+
# Make sure there were no extraneous keywords
1680+
if kwargs:
1681+
raise TypeError("unrecognized keyword(s): ", str(kwargs))
1682+
16831683
# Sanity checking on the input
16841684
if not isinstance(sys, InputOutputSystem):
16851685
raise TypeError("System of type ", type(sys), " not valid")

control/stochsys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .statesp import StateSpace, _ssmatrix
2727
from .exception import ControlArgument, ControlNotImplemented
2828

29-
__all__ = ['lqe','dlqe', 'create_estimator_iosystem', 'white_noise',
29+
__all__ = ['lqe', 'dlqe', 'create_estimator_iosystem', 'white_noise',
3030
'correlation']
3131

3232

@@ -134,7 +134,7 @@ def lqe(*args, **kwargs):
134134
# Get the method to use (if specified as a keyword)
135135
method = kwargs.pop('method', None)
136136
if kwargs:
137-
raise TypeError("unrecognized kwargs: ", str(kwargs))
137+
raise TypeError("unrecognized keyword(s): ", str(kwargs))
138138

139139
# Get the system description
140140
if (len(args) < 3):
@@ -255,7 +255,7 @@ def dlqe(*args, **kwargs):
255255
# Get the method to use (if specified as a keyword)
256256
method = kwargs.pop('method', None)
257257
if kwargs:
258-
raise TypeError("unrecognized kwargs: ", str(kwargs))
258+
raise TypeError("unrecognized keyword(s): ", str(kwargs))
259259

260260
# Get the system description
261261
if (len(args) < 3):

control/tests/iosys_test.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,28 +1711,6 @@ def test_interconnect_unused_output():
17111711
outputs=['y'],
17121712
ignore_outputs=['v'])
17131713

1714-
def test_nonuniform_timepts():
1715-
"""Test non-uniform time points for simulations"""
1716-
sys = ct.LinearIOSystem(ct.rss(2, 1, 1))
1717-
1718-
# Start with a uniform set of times
1719-
unifpts = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1720-
uniform = [1, 2, 3, 2, 1, -1, -3, -5, -7, -3, 1]
1721-
t_unif, y_unif = ct.input_output_response(sys, unifpts, uniform)
1722-
1723-
# Create a non-uniform set of inputs
1724-
noufpts = [0, 2, 4, 8, 10]
1725-
nonunif = [1, 3, 1, -7, 1]
1726-
t_nouf, y_nouf = ct.input_output_response(sys, noufpts, nonunif)
1727-
1728-
# Make sure the outputs agree at common times
1729-
np.testing.assert_almost_equal(y_unif[noufpts], y_nouf, decimal=6)
1730-
1731-
# Resimulate using a new set of evaluation points
1732-
t_even, y_even = ct.input_output_response(
1733-
sys, noufpts, nonunif, t_eval=unifpts)
1734-
np.testing.assert_almost_equal(y_unif, y_even, decimal=6)
1735-
17361714
def test_input_output_broadcasting():
17371715
# Create a system, time vector, and noisy input
17381716
sys = ct.rss(6, 2, 3)
@@ -1773,3 +1751,25 @@ def test_input_output_broadcasting():
17731751
with pytest.raises(ValueError, match="inconsistent"):
17741752
resp_bad = ct.input_output_response(
17751753
sys, T, (U[0, :], U[:2, :-1]), [X0, P0])
1754+
1755+
def test_nonuniform_timepts():
1756+
"""Test non-uniform time points for simulations"""
1757+
sys = ct.LinearIOSystem(ct.rss(2, 1, 1))
1758+
1759+
# Start with a uniform set of times
1760+
unifpts = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1761+
uniform = [1, 2, 3, 2, 1, -1, -3, -5, -7, -3, 1]
1762+
t_unif, y_unif = ct.input_output_response(sys, unifpts, uniform)
1763+
1764+
# Create a non-uniform set of inputs
1765+
noufpts = [0, 2, 4, 8, 10]
1766+
nonunif = [1, 3, 1, -7, 1]
1767+
t_nouf, y_nouf = ct.input_output_response(sys, noufpts, nonunif)
1768+
1769+
# Make sure the outputs agree at common times
1770+
np.testing.assert_almost_equal(y_unif[noufpts], y_nouf, decimal=6)
1771+
1772+
# Resimulate using a new set of evaluation points
1773+
t_even, y_even = ct.input_output_response(
1774+
sys, noufpts, nonunif, t_eval=unifpts)
1775+
np.testing.assert_almost_equal(y_unif, y_even, decimal=6)

control/tests/kwargs_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ def test_unrecognized_kwargs():
8181
sys = control.ss([[-1, 1], [0, -1]], [[0], [1]], [[1, 0]], 0, dt=None)
8282

8383
table = [
84+
[control.dlqe, (sys, [[1]], [[1]]), {}],
8485
[control.dlqr, (sys, [[1, 0], [0, 1]], [[1]]), {}],
8586
[control.drss, (2, 1, 1), {}],
8687
[control.input_output_response, (sys, [0, 1, 2], [1, 1, 1]), {}],
88+
[control.lqe, (sys, [[1]], [[1]]), {}],
8789
[control.lqr, (sys, [[1, 0], [0, 1]], [[1]]), {}],
8890
[control.linearize, (sys, 0, 0), {}],
8991
[control.pzmap, (sys,), {}],
@@ -154,13 +156,15 @@ def test_matplotlib_kwargs():
154156
'bode': test_matplotlib_kwargs,
155157
'bode_plot': test_matplotlib_kwargs,
156158
'describing_function_plot': test_matplotlib_kwargs,
159+
'dlqe': test_unrecognized_kwargs,
157160
'dlqr': statefbk_test.TestStatefbk.test_lqr_errors,
158161
'drss': test_unrecognized_kwargs,
159162
'gangof4': test_matplotlib_kwargs,
160163
'gangof4_plot': test_matplotlib_kwargs,
161164
'input_output_response': test_unrecognized_kwargs,
162165
'interconnect': interconnect_test.test_interconnect_exceptions,
163166
'linearize': test_unrecognized_kwargs,
167+
'lqe': test_unrecognized_kwargs,
164168
'lqr': statefbk_test.TestStatefbk.test_lqr_errors,
165169
'nyquist': test_matplotlib_kwargs,
166170
'nyquist_plot': test_matplotlib_kwargs,

0 commit comments

Comments
 (0)