Skip to content

Commit

Permalink
fixed bug with minimum module installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide-sd committed Apr 12, 2024
1 parent 5225ad8 commit 8af6ba8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions spb/graphics/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)):
Expand Down

0 comments on commit 8af6ba8

Please sign in to comment.