Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f86b41

Browse files
committed
adjust for PEP8 coding style
1 parent6b51432 commit9f86b41

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
ifnotself.issiso():
213213
raiseTypeError("system should be a SISO system")
214-
215-
ifnot(np.isscalar(dbdrop))ordbdrop>=0:
214+
215+
if(notnp.isscalar(dbdrop))ordbdrop>=0:
216216
raiseValueError("expecting dbdrop be a negative scalar in dB")
217217

218218
dcgain=self.dcgain()
219219
ifnp.isinf(dcgain):
220+
# infinite dcgain, return np.nan
220221
returnnp.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
ifidx_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
returnnp.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
importscipy
234-
result=scipy.optimize.root_scalar(lambdaw: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+
lambdaw: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
ifresult.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
>>> G = ct.tf([1], [1, 1])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp