Skip to content

Commit 1f51526

Browse files
committed
update parameter doc and error message for forced_response
1 parent f1a9860 commit 1f51526

2 files changed

Lines changed: 23 additions & 24 deletions

File tree

control/tests/timeresp_test.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
"""timeresp_test.py - test time response functions
2-
3-
RMM, 17 Jun 2011 (based on TestMatlab from v0.4c)
4-
5-
This test suite just goes through and calls all of the MATLAB
6-
functions using different systems and arguments to make sure that
7-
nothing crashes. It doesn't test actual functionality; the module
8-
specific unit tests will do that.
9-
"""
1+
"""timeresp_test.py - test time response functions"""
102

113
from copy import copy
124
from distutils.version import StrictVersion

control/timeresp.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,38 +212,40 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
212212
Time steps at which the input is defined; values must be evenly spaced.
213213
214214
U : array_like or float, optional
215-
Input array giving input at each time `T` (default = 0).
215+
Input array giving input at each time `T`
216216
217217
If `U` is ``None`` or ``0``, a special algorithm is used. This special
218218
algorithm is faster than the general algorithm, which is used
219219
otherwise.
220220
221221
X0 : array_like or float, optional
222-
Initial condition (default = 0).
222+
Initial condition.
223223
224224
transpose : bool, optional
225225
If True, transpose all input and output arrays (for backward
226-
compatibility with MATLAB and :func:`scipy.signal.lsim`). Default
227-
value is False.
226+
compatibility with MATLAB and :func:`scipy.signal.lsim`).
228227
229-
interpolate : bool, optional (default=False)
228+
interpolate : bool, optional
230229
If True and system is a discrete time system, the input will
231230
be interpolated between the given time steps and the output
232231
will be given at system sampling rate. Otherwise, only return
233232
the output at the times given in `T`. No effect on continuous
234-
time simulations (default = False).
233+
time simulations.
235234
236235
return_x : bool, optional
237-
If True (default), return the the state vector. Set to False to
238-
return only the time and output vectors.
236+
- If False, return only the time and output vectors.
237+
- If True, also return the the state vector.
238+
- If None, determine the returned variables by
239+
config.defaults['forced_response.return_x'], which was True
240+
before version 0.9 and is False since then.
239241
240242
squeeze : bool, optional
241243
By default, if a system is single-input, single-output (SISO) then
242244
the output response is returned as a 1D array (indexed by time). If
243245
squeeze=True, remove single-dimensional entries from the shape of
244246
the output even if the system is not SISO. If squeeze=False, keep
245247
the output as a 2D array (indexed by the output number and time)
246-
even if the system is SISO. The default value can be set using
248+
even if the system is SISO. The default value can be overruled by
247249
config.defaults['control.squeeze_time_response'].
248250
249251
Returns
@@ -252,13 +254,15 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
252254
Time values of the output.
253255
254256
yout : array
255-
Response of the system. If the system is SISO and squeeze is not
257+
Response of the system. If the system is SISO and `squeeze` is not
256258
True, the array is 1D (indexed by time). If the system is not SISO or
257-
squeeze is False, the array is 2D (indexed by the output number and
259+
`squeeze` is False, the array is 2D (indexed by the output number and
258260
time).
259261
260262
xout : array
261-
Time evolution of the state vector. Not affected by squeeze.
263+
Time evolution of the state vector. Not affected by squeeze. Only
264+
returned if `return_x` is True, or `return_x` is None and
265+
config.defaults['forced_response.return_x'] is True.
262266
263267
See Also
264268
--------
@@ -297,7 +301,7 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
297301
sys = _convert_to_statespace(sys)
298302
A, B, C, D = np.asarray(sys.A), np.asarray(sys.B), np.asarray(sys.C), \
299303
np.asarray(sys.D)
300-
# d_type = A.dtype
304+
# d_type = A.dtype
301305
n_states = A.shape[0]
302306
n_inputs = B.shape[1]
303307
n_outputs = C.shape[0]
@@ -332,8 +336,11 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
332336
# T must be array-like and values must be increasing.
333337
# The length of T determines the length of the input vector.
334338
if T is None:
335-
raise ValueError('Parameter ``T``: must be array-like, and contain '
336-
'(strictly monotonic) increasing numbers.')
339+
if not isdtime(sys, strict=True):
340+
errmsg_ctime = 'is mandatory for continuous time systems, '
341+
raise ValueError('Parameter ``T`` ' + errmsg_ctime + 'must be '
342+
'array-like, and contain (strictly monotonic) '
343+
'increasing numbers.')
337344
T = _check_convert_array(T, [('any',), (1, 'any')],
338345
'Parameter ``T``: ', squeeze=True,
339346
transpose=transpose)

0 commit comments

Comments
 (0)