我有两个嵌套列表,我想计算两个列表中每个元素的残基。
Coeff_zeros = [(sympy.poly(expand(index_of_zero_e_m[i][1]), s).coeffs()) for i in violates]
Coeff_zeros_index = list(zip(violates, Coeff_zeros))
和
Coeff_poles = [(sympy.poly(expand(index_of_est_pole_m[i][1]), s).coeffs()) for i in violates]
Coeff_poles_index = list(zip(violates, Coeff_poles))
当我使用以下代码时,出现上述错误:
from scipy.signal import residue
Modified_residues = [residue(Coeff_zeros_index[i][1], Coeff_poles_index[i][1]) for i in violates]
但是,当我将Coeff_zeros_index
和Coeff_poles_index
的结果复制并粘贴到我的代码中时,相同的代码可以正常工作。有什么问题,我该怎么办?为什么打印结果可以解决错误?
我不能每次都将两个列表的结果复制并粘贴到我的代码中。
当我打印Coeff_poles_index
时,我会得到:
Coeff_poles_index = [(0, [1.00000000000000, 5426987090.44496]), (1, [1.00000000000000, 1207636905.04548]), (2, [1.00000000000000, 590484627.473621, 8.12581014483133e+19])]
,Coeff_zeros_index
的结果是:
Coeff_zeros_index = [(0, [1.00000000000000, 80787271317.5307]), (1, [1.00000000000000, 13905630041.1712]), (2, [1.00000000000000, 332812172952.372, 4.17475738734003e+20])