numpy.isrealobj#
- numpy.isrealobj(x)[原始碼]#
Return True if x is a not complex type or an array of complex numbers.
The type of the input is checked, not the value. So even if the input has an imaginary part equal to zero,
isrealobjevaluates to False if the data type is complex.- 參數:
- xany
The input can be of any type and shape.
- 回傳值:
- ybool
The return value, False if x is of a complex type.
也參考
Notes
The function is only meant for arrays with numerical values but it accepts all other objects. Since it assumes array input, the return value of other objects may be True.
>>> np.isrealobj('A string') True >>> np.isrealobj(False) True >>> np.isrealobj(None) True
範例
>>> import numpy as np >>> np.isrealobj(1) True >>> np.isrealobj(1+0j) False >>> np.isrealobj([3, 1+0j, True]) False