replace np.pi with math.pi (avoids Mock() issues) + docstring update … · python-control/python-control@aa6e0df
@@ -44,6 +44,7 @@
4444import matplotlib.pyplot as plt
4545import scipy as sp
4646import numpy as np
47+import math
4748from .ctrlutil import unwrap
4849from .bdalg import feedback
4950@@ -128,7 +129,7 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
128129else:
129130omega_limits = np.array(omega_limits)
130131if Hz:
131-omega_limits *= 2.*np.pi
132+omega_limits *= 2.*math.pi
132133if omega_num:
133134omega = sp.logspace(np.log10(omega_limits[0]), np.log10(omega_limits[1]), num=omega_num, endpoint=True)
134135else:
@@ -142,7 +143,7 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
142143else:
143144omega_sys = np.array(omega)
144145if sys.isdtime(True):
145-nyquistfrq = 2. * np.pi * 1. / sys.dt / 2.
146+nyquistfrq = 2. * math.pi * 1. / sys.dt / 2.
146147omega_sys = omega_sys[omega_sys < nyquistfrq]
147148# TODO: What distance to the Nyquist frequency is appropriate?
148149else:
@@ -154,9 +155,9 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
154155phase = unwrap(phase)
155156nyquistfrq_plot = None
156157if Hz:
157-omega_plot = omega_sys / (2. * np.pi)
158+omega_plot = omega_sys / (2. * math.pi)
158159if nyquistfrq:
159-nyquistfrq_plot = nyquistfrq / (2. * np.pi)
160+nyquistfrq_plot = nyquistfrq / (2. * math.pi)
160161else:
161162omega_plot = omega_sys
162163if nyquistfrq:
@@ -187,7 +188,7 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
187188# Phase plot
188189ax_phase = plt.subplot(212, sharex=ax_mag);
189190if deg:
190-phase_plot = phase * 180. / np.pi
191+phase_plot = phase * 180. / math.pi
191192else:
192193phase_plot = phase
193194ax_phase.semilogx(omega_plot, phase_plot, *args, **kwargs)
@@ -208,8 +209,8 @@ def genZeroCenteredSeries(val_min, val_max, period):
208209ax_phase.set_yticks(genZeroCenteredSeries(ylim[0], ylim[1], 15.), minor=True)
209210else:
210211ylim = ax_phase.get_ylim()
211-ax_phase.set_yticks(genZeroCenteredSeries(ylim[0], ylim[1], np.pi / 4.))
212-ax_phase.set_yticks(genZeroCenteredSeries(ylim[0], ylim[1], np.pi / 12.), minor=True)
212+ax_phase.set_yticks(genZeroCenteredSeries(ylim[0], ylim[1], math.pi / 4.))
213+ax_phase.set_yticks(genZeroCenteredSeries(ylim[0], ylim[1], math.pi / 12.), minor=True)
213214ax_phase.grid(True, which='both')
214215# ax_mag.grid(which='minor', alpha=0.3)
215216# ax_mag.grid(which='major', alpha=0.9)
@@ -449,7 +450,7 @@ def default_frequency_range(syslist, Hz=None, number_of_samples=None, feature_pe
449450features_ = features_[features_ != 0.0];
450451features = np.concatenate((features, features_))
451452elif sys.isdtime(strict=True):
452-fn = np.pi * 1. / sys.dt
453+fn = math.pi * 1. / sys.dt
453454# TODO: What distance to the Nyquist frequency is appropriate?
454455freq_interesting.append(fn * 0.9)
455456@@ -475,12 +476,12 @@ def default_frequency_range(syslist, Hz=None, number_of_samples=None, feature_pe
475476features = np.array([1.]);
476477477478if Hz:
478-features /= 2.*np.pi
479+features /= 2.*math.pi
479480features = np.log10(features)
480481lsp_min = np.floor(np.min(features) - feature_periphery_decade)
481482lsp_max = np.ceil(np.max(features) + feature_periphery_decade)
482-lsp_min += np.log10(2.*np.pi)
483-lsp_max += np.log10(2.*np.pi)
483+lsp_min += np.log10(2.*math.pi)
484+lsp_max += np.log10(2.*math.pi)
484485else:
485486features = np.log10(features)
486487lsp_min = np.floor(np.min(features) - feature_periphery_decade)