AxFoundation/strax

Conversion to NaN in numpy arrays

Opened this issue · 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

Sorry, i dont understand. What is the bug here?

Sorry Yossi, I should have explained further. In principle this isn't a bug, but it can cause some unexpected behavior in functions such as touching_windows. See for example: [https://github.com/XENONnT/pema/pull/333]

Can you please explain your expected behavior of strax? otherwise i dont see how this issue can be addressed.