strax
strax copied to clipboard
Conversion to NaN in numpy arrays
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