numpy.iscomplexobj(array):此邏輯函數有助於檢查數組的複雜類型或複數數組。即使虛部等於零,它也被視為複雜對象。
參數:
array :[array_like]Input array or object whose elements, we need to test.
返回:
True, if the input array has a complex element; otherwise False
代碼1:
# Python program explaining
# iscomplexobj() function
import numpy as np
in_array = [1, 3, 5, 4]
print ("Input array:", in_array)
output_value = np.iscomplexobj(in_array)
print ("\nIs complex:", output_value)
輸出:
Input array: [1, 3, 5, 4] Is complex: False
代碼2:
# Python Program illustrating
# numpy.iscomplexobj() method
import numpy as geek
# Returns True/False value for each element
a = geek.arange(20).reshape(5, 4)
print("Is complex:\n", geek.iscomplexobj(a))
# Returns True/False value as ans
# because we have mentioned dtpe in the begining
b = geek.arange(20).reshape(5, 4).dtype = complex
print("\n",b)
print("\nIs complex:", geek.iscomplexobj(b))
b = [[1j],
[3]]
print("\nIs complex:\n", geek.iscomplexobj(b))
輸出:
Is complex: False class 'complex' Is complex: False Is complex: True
相關用法
注:本文由純淨天空篩選整理自Mohit Gupta_OMG 大神的英文原創作品 numpy.iscomplexobj() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。