set very low values to zero in numpy

前端 未结 6 557
傲寒
傲寒 2020-12-06 04:16

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

6条回答
  •  鱼传尺愫
    2020-12-06 04:38

    By using the method round(n) of the array

    np.array( [0 +  0.5j, 0.25 + 1.2352444e-24j, 
               0.25+ 0j, 2.46519033e-32 + 0j]  ).round(23)
    

提交回复
热议问题