这个 努比。iscomplex() 函数按元素测试它是否为复数(不是无穷大或不是数字),并将结果作为布尔数组返回。 语法:
null
numpy.iscomplex(array)
参数:
array : [array_like] Input array whose element we want to test
返回:
boolean array containing the result
代码1:
# Python Program illustrating # numpy.iscomplex() method import numpy as geek print ( "Is Complex : " , geek.iscomplex([ 1 + 1j , 1 + 0j ]), "" ) print ( "Is Complex : " , geek.iscomplex([ 0 + 1j , 0 ]), "" ) |
输出:
Is Complex : [ True False] Is Complex : [ True False]
代码2:
# Python Program illustrating # numpy.iscomplex() method import numpy as geek # Returns True/False value for each element a = geek.arange( 20 ).reshape( 5 , 4 ) print ( "Is complex : " , geek.iscomplex(a)) # Returns True/False value as ans # because we have mentioned dtpe in the beginning b = geek.arange( 20 ).reshape( 5 , 4 ).dtype = complex print ( "" ,b) print ( "Is complex : " , geek.iscomplex(b)) b = [[ 1j ], [ 3 ]] print ( "Is complex : " , geek.iscomplex(b)) |
输出:
Is complex : [[False False False False] [False False False False] [False False False False] [False False False False] [False False False False]] Is complex : False Is complex : [[ True] [False]]
参考资料: https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.isfinite.html
注: 这些代码不会在online-ID上运行。请在您的系统上运行它们以探索工作环境。 本文由 莫希特·古普塔(Mohit Gupta_OMG) .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 贡献极客。组织 或者把你的文章寄到contribute@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。
如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END