From 1603e85a992d6a769c7123e8f599842d7eacdd29 Mon Sep 17 00:00:00 2001 From: bnavigator Date: Tue, 29 Dec 2020 23:13:06 +0100 Subject: [PATCH] handle empty pole vector for timevector calculation --- control/timeresp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/control/timeresp.py b/control/timeresp.py index 946fc6270..f4f293bdf 100644 --- a/control/timeresp.py +++ b/control/timeresp.py @@ -846,8 +846,8 @@ def _ideal_tfinal_and_dt(sys, is_step=True): The system whose time response is to be computed is_step : bool Scales the dc value by the magnitude of the nonzero mode since - integrating the impulse response gives - :math:`\int e^{-\lambda t} = -e^{-\lambda t}/ \lambda` + integrating the impulse response gives + :math:`\\int e^{-\\lambda t} = -e^{-\\lambda t}/ \\lambda` Default is True. Returns @@ -900,8 +900,10 @@ def _ideal_tfinal_and_dt(sys, is_step=True): p_u, p = p[m_u], p[~m_u] if p_u.size > 0: m_u = (p_u.real < 0) & (np.abs(p_u.imag) < sqrt_eps) - t_emp = np.max(log_decay_percent / np.abs(np.log(p_u[~m_u])/dt)) - tfinal = max(tfinal, t_emp) + if np.any(~m_u): + t_emp = np.max( + log_decay_percent / np.abs(np.log(p_u[~m_u]) / dt)) + tfinal = max(tfinal, t_emp) # zero - negligible effect on tfinal m_z = np.abs(p) < sqrt_eps