Skip to content

Commit a09e98c

Browse files
committed
move warning to before conversion
1 parent fa58099 commit a09e98c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

control/timeresp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
302302
"return_x specified for a transfer function system. Internal "
303303
"conversion to state space used; results may meaningless.")
304304

305+
# If we are passed a transfer function and X0 is non-zero, warn the user
306+
if isinstance(sys, TransferFunction) and np.any(X0 != 0):
307+
warnings.warn(
308+
"Non-zero initial condition given for transfer function system. "
309+
"Internal conversion to state space used; may not be consistent "
310+
"with given X0.")
311+
305312
sys = _convert_to_statespace(sys)
306313
A, B, C, D = np.asarray(sys.A), np.asarray(sys.B), np.asarray(sys.C), \
307314
np.asarray(sys.D)
@@ -358,12 +365,6 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
358365
X0 = _check_convert_array(X0, [(n_states,), (n_states, 1)],
359366
'Parameter ``X0``: ', squeeze=True)
360367

361-
# If we are passed a transfer function and X0 is non-zero, warn the user
362-
if isinstance(sys, TransferFunction) and np.any(X0 != 0):
363-
warnings.warn(
364-
"Non-zero initial condition given for transfer function system. "
365-
"Internal conversion to state space used; may not be consistent "
366-
"with given X0.")
367368

368369
xout = np.zeros((n_states, n_steps))
369370
xout[:, 0] = X0

0 commit comments

Comments
 (0)