In numpy I have an array like
[0 + 0.5j, 0.25 + 1.2352444e-24j, 0.25+ 0j, 2.46519033e-32 + 0j]
what is the fastest and easiest way to se
If all numbers have small imaginary parts, and you only want to suppress these then you can use
b=np.real_if_close(a)
Otherwise the suggestion by DSM is the way forward, i.e.
a.real[abs(a.real)<1e-13]=0 a.imag[abs(a.imag)<1e-13]=0