Skip to content

Commit d8b70ed

Browse files
committed
a few small code cleanups
1 parent 08dfca5 commit d8b70ed

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

control/freqplot.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,17 @@ def bode_plot(syslist, omega=None,
220220
raise ControlMIMONotImplemented(
221221
"Bode is currently only implemented for SISO systems.")
222222
else:
223-
omega_sys = np.array(omega)
224-
if sys.isdtime(True):
223+
omega_sys = np.asarray(omega)
224+
if sys.isdtime(strict=True):
225225
nyquistfrq = 2. * math.pi * 1. / sys.dt / 2.
226226
omega_sys = omega_sys[omega_sys < nyquistfrq]
227227
# TODO: What distance to the Nyquist frequency is appropriate?
228228
else:
229229
nyquistfrq = None
230230

231-
# Get the magnitude and phase of the system
232-
mag_tmp, phase_tmp, omega_sys = sys.frequency_response(omega_sys)
233-
mag = np.atleast_1d(np.squeeze(mag_tmp))
234-
phase = np.atleast_1d(np.squeeze(phase_tmp))
231+
mag, phase, omega_sys = sys.frequency_response(omega_sys)
232+
mag = np.atleast_1d(mag)
233+
phase = np.atleast_1d(phase)
235234

236235
#
237236
# Post-process the phase to handle initial value and wrapping
@@ -352,8 +351,7 @@ def bode_plot(syslist, omega=None,
352351
# Show the phase and gain margins in the plot
353352
if margins:
354353
# Compute stability margins for the system
355-
margin = stability_margins(sys)
356-
gm, pm, Wcg, Wcp = (margin[i] for i in (0, 1, 3, 4))
354+
gm, pm, Wcg, Wcp = stability_margins(sys)[0:4]
357355

358356
# Figure out sign of the phase at the first gain crossing
359357
# (needed if phase_wrap is True)

0 commit comments

Comments
 (0)