Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion to NaN in numpy arrays #757

Open
JYangQi00 opened this issue Sep 15, 2023 · 3 comments
Open

Conversion to NaN in numpy arrays #757

JYangQi00 opened this issue Sep 15, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@JYangQi00
Copy link
Collaborator

JYangQi00 commented Sep 15, 2023

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 JYangQi00 added the bug Something isn't working label Sep 15, 2023
@jmosbacher
Copy link
Contributor

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

@JYangQi00
Copy link
Collaborator Author

JYangQi00 commented Sep 15, 2023

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]

@jmosbacher
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants