-
Notifications
You must be signed in to change notification settings - Fork 33
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
(corner case) Ban negative indices #121
Comments
How does the conversion from python to rust type work? |
It silently accepts negative integers from python and converts them into unsigned integers in rust https://pyo3.rs/main/conversions/tables (which lead to crazy values) Blanketing our integers before sending them to the rust side shouldn't affect the performance too much if it's your concern? |
My concern was rather about having a single checkpoint. I thought this could be managed on the Rust side, at conversion time, but it seems I'm wrong. |
maybe @fxpineau has an idea on how to do this better? |
In which cases do we end up with negative HEALPix indices that are passed from Python to Rust? Given that pyo3 do not produce and error (so far) when converting from a negative integer to an unsigned integer, we may consider at least two opinions:
I personally have a marked preference for the second bullet (check on Python side), possibly isolating and decorating with a check the call to the Rust method to mitigate the 'cons' (no duplication/no risk to forget, i.e. single checkpoint on the Python side). |
It was discovered due to the I like FX's idea to define a decorator on the python's side. This way there is only one decorator to maintain and we can apply it to all methods that accept healpix cells (just as we already do with the |
Due to the conversion from python
int
to rustu8
negative indices are not rejected and create false MOCs instead.To solve this:
The text was updated successfully, but these errors were encountered: