的返回值butter
取决于output
函数参数,默认为'ba'
. 无论是“突出显示”您的代码,都没有考虑输出值的可变性质,这解释了代码运行正确的原因。
该文档清楚地描述了可能的不同返回值:
>>> help(scipy.signal.butter)
Help on function butter in module scipy.signal.filter_design:
butter(N, Wn, btype='low', analog=False, output='ba', fs=None)
Butterworth digital and analog filter design.
...
Returns
-------
b, a : ndarray, ndarray
Numerator (`b`) and denominator (`a`) polynomials of the IIR filter.
Only returned if ``output='ba'``.
z, p, k : ndarray, ndarray, float
Zeros, poles, and system gain of the IIR filter transfer
function. Only returned if ``output='zpk'``.
sos : ndarray
Second-order sections representation of the IIR filter.
Only returned if ``output=='sos'``.