In [1]:
import numpy as np
In [2]:
a = np.array([-100, -10, 0, 10, 100])
print(a)
In [3]:
print(np.sign(a))
In [4]:
print(type(np.sign(a)))
In [5]:
print(np.sign(a).dtype)
In [6]:
a_float = np.array([-1.23, 0.0, 1.23])
print(a_float)
In [7]:
print(np.sign(a_float))
In [8]:
print(np.sign(a_float).dtype)
In [9]:
print(np.sign(100))
In [10]:
print(type(np.sign(100)))
In [11]:
print(np.sign(-1.23))
In [12]:
print(type(np.sign(-1.23)))
In [13]:
a_special = np.array([0.0, -0.0, np.inf, -np.inf, np.nan])
print(a_special)
In [14]:
print(np.sign(a_special))
In [15]:
print(np.sign(a_special).dtype)
In [16]:
a_complex = np.array([[10 + 10j, -10 + 10j], [10 - 10j, -10 - 10j], [10, -10], [10j, -10j], [0, np.nan], [0j, np.nan * 1j]])
print(a_complex)
In [17]:
print(np.sign(a_complex))
In [18]:
print(a_complex.real)
In [19]:
print(np.sign(a_complex.real))
In [20]:
print(a_complex.imag)
In [21]:
print(np.sign(a_complex.imag))