numpy.iscomplexobj() in Python (original) (raw)
Last Updated : 11 May, 2021
numpy.iscomplexobj(array) : This logical function helps to checks for the complex type of an array or array of a complex number. Even if imaginary part is equal to zero, it is considered to be an Complex Object.
Parameters :
array : [array_like]Input array or object whose elements, we need to test.
Return :
True, if the input array has a complex element; otherwise False
Code 1 :
Python
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)
Output :
Input array : [1, 3, 5, 4]
Is complex : False
Code 2 :
Python
import
numpy as geek
a
=
geek.arange(
20
).reshape(
5
,
4
)
print
(
"Is complex : \n"
, geek.iscomplexobj(a))
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))
Output :
Is complex : False
class 'complex'
Is complex : False
Is complex : True
References :
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.iscomplexobj.html#numpy.iscomplexobj
Similar Reads
- numpy.iscomplex() in Python The numpy.iscomplex() function tests element-wise whether it is a complex number or not(not infinity or not Not a Number) and returns the result as a boolean array. Syntax : numpy.iscomplex(array) Parameters : array : [array_like] Input array whose element we want to test Return : boolean array cont 2 min read
- numpy.isrealobj() in Python numpy.isrealobj(array) : This logical function helps to checks if the array has no complex type or array has a complex number. Even if imaginary part is equal to zero, it is not considered to be a Real Object. Parameters : array : [array_like]Input array or object whose elements, we need to test. Re 1 min read
- numpy.isposinf() in Python The numpy.isposinf() function tests element-wise whether it is positive infinity or not and returns the result as a boolean array. Syntax : numpy.isposinf(array, y = None) Parameters: array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boolean ar 2 min read
- numpy.isscalar() in Python In this article, we will elucidate the `numpy.isscalar()` function through a well-documented code example and comprehensive explanation. Python numpy.isscalar() Syntax Syntax : numpy.isscalar(element) Parameters: element: The input element to be checked for scalar properties.Return Type: bool: Retur 3 min read
- numpy.isreal() in Python numpy.isreal(array) : Test element-wise whether it is a real number or not(not infinity or not Not a Number) and return the result as a boolean array. Parameters : array : [array_like] Input array whose element we want to test Return : boolean array containing the result Code 1 : Python Code # Pytho 2 min read
- numpy.less() in Python The numpy.less() : checks whether x1 is lesser than x2 or not. Syntax : numpy.less(x1, x2[, out]) Parameters : x1, x2 : [array_like]Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape out : [ndarray, boolean]Array of bools, or a single bool if x1 and x2 are scalars. R 2 min read
- numpy.isnan() in Python The numpy.isnan() function tests element-wise whether it is NaN or not and returns the result as a boolean array. Syntax : numpy.isnan(array [, out]) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity out : [ndarray, optional]Output array placed with 2 min read
- numpy.isinf() in Python The numpy.isinf() function tests element-wise whether it is +ve or -ve infinity or not return the result as a boolean array. Syntax: numpy.isinf(array [, out]) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity out : [ndarray, optional]Output array pl 2 min read
- numpy.isneginf() in Python The numpy.isneginf() function tests element-wise whether it is negative infinity or not, and returns the result as a boolean array. Syntax : numpy.isneginf(array, y = None) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boolean 2 min read
- Python | numpy.isin() method With the help of numpy.isin() method, we can see that one array having values are checked in a different numpy array having different elements with different sizes. Syntax : numpy.isin(target_array, list) Return : Return boolean array having same size as of target_array. Example #1 : In this example 1 min read