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
You can also use the numpy.isclose method:
>>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
array([True, False])
By asking if it is close to zero, it should work:
>>> np.isclose([1e10,0], [1.00001e-10,0])
array([False, True])
You can customise the atol (absolute tolerance, defaults to 1e-08) and the rtol (relative tolerance, defaults to 1e-05) parameters. You can then set rtol=0 to only use the absolute tolerance.