Skip to content

Commit 566627b

Browse files
committed
added test for aliases, added docstrings for alias stubs, removed alias for feedback and added stub to LTI
1 parent 97ace35 commit 566627b

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

control/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
# all heavily depend on the LTI class
124124
LTI.to_ss = ss
125125
LTI.to_tf = tf
126-
LTI.feedback = feedback
127126
LTI.bode_plot = bode_plot
128127
LTI.nyquist_plot = nyquist_plot
129128
LTI.nichols_plot = nichols_plot

control/lti.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,33 @@ def ispassive(self):
210210
# importing here prevents circular dependancy
211211
from control.passivity import ispassive
212212
return ispassive(self)
213+
214+
def feedback(self, other=1, sign=-1):
215+
raise NotImplementedError(f"feedback not implemented for base {self.__class__.__name__} objects")
213216

214217
# convenience aliases
215218
# most function are only forward declaraed and patched in the __init__.py to avoid circular imports
216219

217220
# conversions
221+
#: Convert to :class:`StateSpace` representation; see :func:`ss`
218222
to_ss: Callable
223+
#: Convert to :class:`TransferFunction` representation; see :func:`tf`
219224
to_tf: Callable
220225

221-
# system interconnections
222-
feedback: Callable
223-
224226
# freq domain plotting
227+
#: Bode plot; see :func:`bode_plot`
225228
bode_plot: Callable
229+
#: Nyquist plot; see :func:`nyquist_plot`
226230
nyquist_plot: Callable
231+
#: Nichols plot; see :func:`nichols_plot`
227232
nichols_plot: Callable
228233

229234
# time domain simulation
235+
#: Forced response; see :func:`forced_response`
230236
forced_response = control.timeresp.forced_response
237+
#: Impulse response; see :func:`impulse_response`
231238
impulse_response = control.timeresp.impulse_response
239+
#: Step response; see :func:`step_response`
232240
step_response = control.timeresp.step_response
233241

234242

control/tests/kwargs_test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def test_response_plot_kwargs(data_fcn, plot_fcn, mimo):
244244
'append': test_unrecognized_kwargs,
245245
'bode': test_response_plot_kwargs,
246246
'bode_plot': test_response_plot_kwargs,
247-
'LTI.bode_plot': test_response_plot_kwargs,
247+
'LTI.bode_plot': test_response_plot_kwargs, # alias for bode_plot and tested via bode_plot
248248
'create_estimator_iosystem': stochsys_test.test_estimator_errors,
249249
'create_statefbk_iosystem': statefbk_test.TestStatefbk.test_statefbk_errors,
250250
'describing_function_plot': test_matplotlib_kwargs,
@@ -254,7 +254,6 @@ def test_response_plot_kwargs(data_fcn, plot_fcn, mimo):
254254
'dlqr': test_unrecognized_kwargs,
255255
'drss': test_unrecognized_kwargs,
256256
'feedback': test_unrecognized_kwargs,
257-
'LTI.feedback': test_unrecognized_kwargs,
258257
'find_eqpt': iosys_test.test_find_operating_point,
259258
'find_operating_point': iosys_test.test_find_operating_point,
260259
'flatsys.flatsys': test_unrecognized_kwargs,
@@ -269,13 +268,13 @@ def test_response_plot_kwargs(data_fcn, plot_fcn, mimo):
269268
'lqr': test_unrecognized_kwargs,
270269
'negate': test_unrecognized_kwargs,
271270
'nichols_plot': test_matplotlib_kwargs,
272-
'LTI.nichols_plot': test_matplotlib_kwargs,
271+
'LTI.nichols_plot': test_matplotlib_kwargs, # alias for nichols_plot and tested via nichols_plot
273272
'nichols': test_matplotlib_kwargs,
274273
'nlsys': test_unrecognized_kwargs,
275274
'nyquist': test_matplotlib_kwargs,
276275
'nyquist_response': test_response_plot_kwargs,
277276
'nyquist_plot': test_matplotlib_kwargs,
278-
'LTI.nyquist_plot': test_matplotlib_kwargs,
277+
'LTI.nyquist_plot': test_matplotlib_kwargs, # alias for nyquist_plot and tested via nyquist_plot
279278
'phase_plane_plot': test_matplotlib_kwargs,
280279
'parallel': test_unrecognized_kwargs,
281280
'pole_zero_plot': test_unrecognized_kwargs,

control/tests/statesp_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,31 @@ def test_tf2ss_mimo():
12811281
else:
12821282
with pytest.raises(ct.ControlMIMONotImplemented):
12831283
sys_ss = ct.ss(sys_tf)
1284+
1285+
def test_convenience_aliases():
1286+
sys = ct.StateSpace(1, 1, 1, 1)
1287+
1288+
# test that all the aliases point to the correct function
1289+
# .__funct__ a bound methods underlying function
1290+
assert sys.to_ss.__func__ == ct.ss
1291+
assert sys.to_tf.__func__ == ct.tf
1292+
assert sys.bode_plot.__func__ == ct.bode_plot
1293+
assert sys.nyquist_plot.__func__ == ct.nyquist_plot
1294+
assert sys.nichols_plot.__func__ == ct.nichols_plot
1295+
assert sys.forced_response.__func__ == ct.forced_response
1296+
assert sys.impulse_response.__func__ == ct.impulse_response
1297+
assert sys.step_response.__func__ == ct.step_response
1298+
assert sys.initial_response.__func__ == ct.initial_response
1299+
1300+
# make sure the functions can be used as member function ie they support
1301+
# an instance of StateSpace as the first argument and that they at least return
1302+
# the correct type
1303+
assert isinstance(sys.to_ss(), StateSpace)
1304+
assert isinstance(sys.to_tf(), TransferFunction)
1305+
assert isinstance(sys.bode_plot(), ct.ControlPlot)
1306+
assert isinstance(sys.nyquist_plot(), ct.ControlPlot)
1307+
assert isinstance(sys.nichols_plot(), ct.ControlPlot)
1308+
assert isinstance(sys.forced_response([0, 1], [1, 1]), (ct.TimeResponseData, ct.TimeResponseList))
1309+
assert isinstance(sys.impulse_response(), (ct.TimeResponseData, ct.TimeResponseList))
1310+
assert isinstance(sys.step_response(), (ct.TimeResponseData, ct.TimeResponseList))
1311+
assert isinstance(sys.initial_response(X0=1), (ct.TimeResponseData, ct.TimeResponseList))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy