【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part

【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part,第1张

概述运行代码:importnumpyasnpnp.seterr(all=\'warn\')A=np.array([10])a=A[-1]a**a报错:ComplexWarning:Castingcomplexvaluestorealdiscardstheimaginarypart

运行代码:

报错:

ComplexWarning: Casting complex values to real discards the imaginary part

(将复数转换为实数丢弃虚部)

原因:

a是int32,能表示的最大数是2**32-1,而10**10显然超出这个范围;


原文地址:

https://stackoverflow.com/questions/7559595/python-runtimewarning-overflow-encountered-in-long-scalars

总结

以上是内存溢出为你收集整理的【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part全部内容,希望文章能够帮你解决【Python报错】ComplexWarning: Casting complex values to real discards the imaginary part所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1209160.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)