only size-1 arrays can be converted to Python scalars解决方法
定义了如下函数import numpy as np import mathdef f(x): return 1-x-math.sin(x)当我在主函数执行如下代码时x = linspace(0,1,1000)y = f(x)系统提示错误信息:only size-1 arrays can be converted to Python scalars上网查了一下,还是由不少人遇到过类似问题,我的解决方法是,将math.sin(x)改为np.sin(x),然后就OK了。。。。。。.
原创
2020-05-25 21:14:20 ·
44010 阅读 ·
7 评论