Comments (6)
It was discovered due to the -1
that is used as padding in cdshealpix.neighbors
when a cell has three neighbors instead of four. This generates a set of healpix's cells with spurious -1
among them.
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 validate_lonlat
decorator that ensures that all coordinates sent to the rust side are in degrees, in icrs, and are wrapped)
from mocpy.
How does the conversion from python to rust type work?
Could this issue be solved on the Rust side?
from mocpy.
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)
I think it fits in this pyO3 issue but I'm not sure PyO3/pyo3#3226
Blanketing our integers before sending them to the rust side shouldn't affect the performance too much if it's your concern?
from mocpy.
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.
from mocpy.
maybe @fxpineau has an idea on how to do this better?
from mocpy.
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:
- prefer to have a single checkpoint on the Rust side: technically, I could accept signed integers on the Rust side, and then filter and cast into unsigned integer. Pros: no duplicated code / no risk to forget to check. Cons: 1. performance penalty for cases in which we are sure that all indices are ok (i.e. when checking is useless), 2. write code that would not exist if pyo3 behavior was to return an error;
- prefer having a method checking (and cleaning) an array of HEALPix index on the Python side, and call it when necessary: we consider that the Rust method (accepting only unsigned integer) is a contract that must be fulfill, and the Python code calling the method has the responsibility to ensure it, identifying beforehand cases in which the contract may be broken (pros/cons are reversed with respect to the first bullet pros/cons).
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).
from mocpy.
Related Issues (20)
- `new_empty` is not implemented for STMOCs
- rewrite doc of MOC.from_ methods
- MOC to STC-S HOT 3
- MOC overlap with a MRM: calculation of proba in the intersection HOT 14
- MOCServer Cancells request on HST coverage (MOC too big) HOT 3
- MOC sky area HOT 5
- mocpy probability calculation when using multiprocessing HOT 21
- garbage collector stumbles when a MOC is pickled
- Parallelized (on the Rust side) MOC generation HOT 25
- Remove deprecated plot methods
- Multiple Subplotting Issue/help HOT 4
- PyPI wheels for manylinux2014 x86_64 HOT 3
- from_vizier_table returns empty MOC silently on incorrect table names HOT 4
- Max, min, median, average Distance in a region HOT 10
- Support of numpy 2.0 HOT 1
- JSON serialization of empty space MOC fails HOT 2
- moc.union(moc1, moc2) fails with TypeError HOT 5
- `from_healpix_cells` no longer allows HEALPix cells with index 0 HOT 3
- MOC.from_astropy_regions doesn't work with boxes with height > width HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mocpy.