GaelVaroquaux/nipy — comment on commit 280432f02397891440e5a57458c65af1eab5ad0b
File: nipy/labs/mask.py line 387
By matthew-brett:

If there are NaNs, and 'dtype' is not a floating point type, terrible things may happen:

In [85]: for t in np.sctypes['int'] + np.sctypes['uint']:
....: print np.array([np.nan], float).astype(t)
....:
[0]
[0]
[-2147483648]
[-2147483648]
[-9223372036854775808]
[0]
[0]
[2147483648]
[2147483648]
[9223372036854775808]

It would be safer to fix the nans (and probably any +/- infs) before casting...