diff --git a/spb/graphics/control.py b/spb/graphics/control.py index b746a0e..2515f74 100644 --- a/spb/graphics/control.py +++ b/spb/graphics/control.py @@ -530,10 +530,13 @@ def _set_lower_upper_limits(system, lower_limit, upper_limit, lower_limit = 0 if not upper_limit: tfinal = None - if not kwargs.get("params", None): + ct = import_module("control") + if ct and (not kwargs.get("params", None)): + # this procedure requires the control module control_sys = tf_to_control(system) tfinal, _ = _ideal_tfinal_and_dt(control_sys, is_step=is_step) - # if interactive widget plot, use default value of 10 + # if interactive widget plot, or control is not installed, use + # default value of 10 upper_limit = tfinal if tfinal else 10 return lower_limit, upper_limit diff --git a/spb/utils.py b/spb/utils.py index 2d9bca6..dbe3776 100644 --- a/spb/utils.py +++ b/spb/utils.py @@ -756,7 +756,7 @@ def _from_sympy_to_ct(num, den): ) return ct.tf(n, d) - if isinstance(tf, ct.TransferFunction): + if ct and isinstance(tf, ct.TransferFunction): return tf if isinstance(tf, Expr): @@ -780,7 +780,7 @@ def _from_sympy_to_ct(num, den): den.append(row_den) return ct.tf(num, den) - elif isinstance(tf, sp.signal.TransferFunction): + elif sp and isinstance(tf, sp.signal.TransferFunction): return ct.tf(tf.num, tf.den, dt=0 if tf.dt is None else tf.dt) elif isinstance(tf, (list, tuple)):