我正在尝试使用scipy.integrate.romberg进行集成,但是我收到有关IndexError的错误消息:
ERROR: IndexError: 0-d arrays can't be indexed [scipy.integrate.quadrature]
Traceback (most recent call last):
File "ucmh.py", line 137, in <module>
main()
File "ucmh.py", line 128, in main
avg_rho_ucmh_squared(mDM, sigma_v, 10**5)
File "ucmh.py", line 119, in avg_rho_ucmh_squared
return n_ucmh(z) * integrate.romberg(integrand,0,R_h(z))
File "/usr/lib/python2.7/dist-packages/scipy/integrate/quadrature.py", line 596, in romberg
ordsum = _difftrap(vfunc, interval, n)
File "/usr/lib/python2.7/dist-packages/scipy/integrate/quadrature.py", line 477, in _difftrap
return 0.5*(function(interval[0])+function(interval[1]))
File "/usr/lib/python2.7/dist-packages/scipy/integrate/quadrature.py", line 94, in vfunc
y0 = func(x[0], *args)
IndexError: 0-d arrays can't be indexed
什么可能导致这个问题?
答案 0 :(得分:0)
我的错误是astropy.units对象集成的输入之一,所以它显然是一个数组,我应该传递值而不是astropy.units对象