Skip to content

Commit 52d8fc3

Browse files
committed
improve error message display, ease poly to frd check
1 parent 4381a7e commit 52d8fc3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

control/margins.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def _likely_numerical_inaccuracy(sys):
218218
# * z**(-p_q)
219219
x = [1] + [0] * (-p_q)
220220
p1 = np.polymul(p1, x)
221-
return np.linalg.norm(p1) < 1e-3 * np.linalg.norm(p2)
221+
return np.linalg.norm(p1) < 1e-4 * np.linalg.norm(p2)
222222

223223
# Took the framework for the old function by
224224
# Sawyer B. Fuller <minster@uw.edu>, removed a lot of the innards
@@ -337,7 +337,8 @@ def stability_margins(sysdata, returnall=False, epsw=0.0, method='best'):
337337
if isinstance(sys, xferfcn.TransferFunction) and not sys.isctime():
338338
if _likely_numerical_inaccuracy(sys):
339339
warn("stability_margins: Falling back to 'frd' method "
340-
"because of chance of numerical inaccuracy in 'poly' method.")
340+
"because of chance of numerical inaccuracy in 'poly' method.",
341+
stacklevel=2)
341342
omega_sys = freqplot._default_frequency_range(sys)
342343
omega_sys = omega_sys[omega_sys < np.pi / sys.dt]
343344
sys = frdata.FRD(sys, omega_sys, smooth=True)

0 commit comments

Comments
 (0)