8000 adjust for PEP8 coding style · python-control/python-control@d59d19a · GitHub
[go: up one dir, main page]

Skip to content

Commit d59d19a

Browse files
committed
adjust for PEP8 coding style
1 parent 0c81cb2 commit d59d19a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

control/lti.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,13 @@ def _bandwidth(self, dbdrop=-3):
211211
# check if system is SISO and dbdrop is a negative scalar
212212
if not self.issiso():
213213
raise TypeError("system should be a SISO system")
214-
215-
if not(np.isscalar(dbdrop)) or dbdrop >= 0:
214+
215+
if (not np.isscalar(dbdrop)) or dbdrop >= 0:
216216
raise ValueError("expecting dbdrop be a negative scalar in dB")
217217

218218
dcgain = self.dcgain()
219219
if np.isinf(dcgain):
220+
# infinite dcgain, return np.nan
220221
return np.nan
221222

222223
# use frequency range to identify the 0-crossing (dbdrop) bracket
@@ -226,14 +227,16 @@ def _bandwidth(self, dbdrop=-3):
226227
idx_dropped = np.nonzero(mag - dcgain*10**(dbdrop/20) < 0)[0]
227228

228229
if idx_dropped.shape[0] == 0:
229-
# no frequency response is dbdrop below the dc gain.
230+
# no frequency response is dbdrop below the dc gain, return np.inf
230231
return np.inf
231232
else:
232-
# solve for the bandwidth, use scipy.optimize.root_scalar() to solve using bisection
233+
# solve for the bandwidth, use scipy.optimize.root_scalar() to
234+
# solve using bisection
233235
import scipy
234-
result = scipy.optimize.root_scalar(lambda w: np.abs(self(w*1j)) - np.abs(dcgain)*10**(dbdrop/20),
235-
bracket=[omega[idx_dropped[0] - 1], omega[idx_dropped[0]]],
236-
method='bisect')
236+
result = scipy.optimize.root_scalar(
237+
lambda w: np.abs(self(w*1j)) - np.abs(dcgain)*10**(dbdrop/20),
238+
bracket=[omega[idx_dropped[0] - 1], omega[idx_dropped[0]]],
239+
method='bisect')
237240

238241
# check solution
239242
if result.converged:
@@ -552,16 +555,17 @@ def bandwidth(sys, dbdrop=-3):
552555
Returns
553556
-------
554557
bandwidth : ndarray
555-
The first frequency (rad/time-unit) where the gain drops below dbdrop of the dc gain
556-
of the system, or nan if the system has infinite dc gain, inf if the gain does not drop for all frequency
558+
The first frequency (rad/time-unit) where the gain drops below dbdrop
559+
of the dc gain of the system, or nan if the system has infinite dc
560+
gain, inf if the gain does not drop for all frequency
557561
558562
Raises
559563
------
560564
TypeError
561565
if 'sys' is not an SISO LTI instance
562566
ValueError
563567
if 'dbdrop' is not a negative scalar
564-
568+
565569
Example
566570
-------
567571
3793 >>> G = ct.tf([1], [1, 1])

0 commit comments

Comments
 (0)
0