strax icon indicating copy to clipboard operation
strax copied to clipboard

Conversion to NaN in numpy arrays

Open JYangQi00 opened this issue 1 year ago • 3 comments

Describe the bug When NaNs are cast as integer or float types (e.g. int64), it converts it to a large negative number, rather than being recognized as NaN. This can be seen in the following examples:

To Reproduce

np.repeat(np.nan, 20).astype('int64')

will return an array of -9223372036854775808

Similarly, if we have an array of NaN's and we copy it, we will also face this issue.

x = np.zeros(20, dtype = [('endtime', np.int64)])
x['endtime'] = np.repeat(np.nan, 20).copy()

will similarly return an array of -9223372036854775808

JYangQi00 avatar Sep 15 '23 08:09 JYangQi00