[SciPy-user] replacing numpy.inf in an array fast with 0.0 ?
kxroberto at googlemail.com
Thu Nov 23 10:47:27 CST 2006
>> print z
>> Maybe there is a more efficient way.
> I am a beginner with numpy myself too, but I am used to do this in
> Matlab by using boolean arrays to index an array. If the same trick
> works in scipy/numpy you should be able to do
> z[isinf(z)] = 0.0
> z[isnan(z)] = 0.0
> saving you the call to where.
infact. its magic short :-)
More information about the SciPy-user