Open In App

numpy.iscomplexobj() in Python

Last Updated : 11 May, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

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
# 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)

Output : 

Input array :  [1, 3, 5, 4]

Is complex :  False

Code 2 :  

Python
# 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 beginning
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 
 


Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy