Skip to content

Commit 13f3870

Browse files
committed
added aliases of selected functions as member functions to LTI
1 parent 4ce7b08 commit 13f3870

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

control/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,15 @@
118118
except ImportError:
119119
__version__ = "dev"
120120

121+
# patch the LTI class with function aliases for convenience functions
122+
# this needs to be done after the fact since the modules that contain the functions
123+
# all heavily depend on the LTI class
124+
LTI.to_ss = ss
125+
LTI.to_tf = tf
126+
LTI.feedback = feedback
127+
LTI.bode_plot = bode_plot
128+
LTI.nyquist_plot = nyquist_plot
129+
LTI.nichols_plot = nichols_plot
130+
121131
# Initialize default parameter values
122132
reset_defaults()

control/lti.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from warnings import warn
1212
from . import config
1313
from .iosys import InputOutputSystem
14+
import control
15+
from typing import Callable
1416

1517
__all__ = ['poles', 'zeros', 'damp', 'evalfr', 'frequency_response',
1618
'freqresp', 'dcgain', 'bandwidth', 'LTI']
@@ -203,6 +205,26 @@ def ispassive(self):
203205
from control.passivity import ispassive
204206
return ispassive(self)
205207

208+
# convenience aliases
209+
# most function are only forward declaraed and patched in the __init__.py to avoid circular imports
210+
211+
# conversions
212+
to_ss: Callable
213+
to_tf: Callable
214+
215+
# system interconnections
216+
feedback: Callable
217+
218+
# freq domain plotting
219+
bode_plot: Callable
220+
nyquist_plot: Callable
221+
nichols_plot: Callable
222+
223+
# time domain simulation
224+
forced_response = control.timeresp.forced_response
225+
impulse_response = control.timeresp.impulse_response
226+
step_response = control.timeresp.step_response
227+
206228

207229
def poles(sys):
208230
"""

control/statesp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
common_timebase, isdtime, issiso
7171
from .lti import LTI, _process_frequency_response
7272
from .nlsys import InterconnectedSystem, NonlinearIOSystem
73+
import control
7374

7475
try:
7576
from slycot import ab13dd
@@ -1467,6 +1468,9 @@ def output(self, t, x, u=None, params=None):
14671468
raise ValueError("len(u) must be equal to number of inputs")
14681469
return (self.C @ x).reshape((-1,)) \
14691470
+ (self.D @ u).reshape((-1,)) # return as row vector
1471+
1472+
# convenience aliase, import needs to go over the submodule to avoid circular imports
1473+
initial_response = control.timeresp.initial_response
14701474

14711475

14721476
class LinearICSystem(InterconnectedSystem, StateSpace):

control/tests/kwargs_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +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,
247248
'create_estimator_iosystem': stochsys_test.test_estimator_errors,
248249
'create_statefbk_iosystem': statefbk_test.TestStatefbk.test_statefbk_errors,
249250
'describing_function_plot': test_matplotlib_kwargs,
@@ -253,6 +254,7 @@ def test_response_plot_kwargs(data_fcn, plot_fcn, mimo):
253254
'dlqr': test_unrecognized_kwargs,
254255
'drss': test_unrecognized_kwargs,
255256
'feedback': test_unrecognized_kwargs,
257+
'LTI.feedback': test_unrecognized_kwargs,
256258
'find_eqpt': iosys_test.test_find_operating_point,
257259
'find_operating_point': iosys_test.test_find_operating_point,
258260
'flatsys.flatsys': test_unrecognized_kwargs,
@@ -267,11 +269,13 @@ def test_response_plot_kwargs(data_fcn, plot_fcn, mimo):
267269
'lqr': test_unrecognized_kwargs,
268270
'negate': test_unrecognized_kwargs,
269271
'nichols_plot': test_matplotlib_kwargs,
272+
'LTI.nichols_plot': test_matplotlib_kwargs,
270273
'nichols': test_matplotlib_kwargs,
271274
'nlsys': test_unrecognized_kwargs,
272275
'nyquist': test_matplotlib_kwargs,
273276
'nyquist_response': test_response_plot_kwargs,
274277
'nyquist_plot': test_matplotlib_kwargs,
278+
'LTI.nyquist_plot': test_matplotlib_kwargs,
275279
'phase_plane_plot': test_matplotlib_kwargs,
276280
'parallel': test_unrecognized_kwargs,
277281
'pole_zero_plot': test_unrecognized_kwargs,

0 commit comments

Comments
 (0)