Open olebole opened 1 year ago
Appendix D of the HEALPix Introduction states:
Note that, due to finite precision of floating-point arithmetics and differences between numerical libraries, the result of HEALPix functions like ang2pix (which converts the angular coordinates of a point into the index of the pixel to which it belongs) may depend on the underlying hardware, compilers, compiler options and linked libraries, if the requested position is very close to (roughly 10^−15 radians or less) a pixel border. [...] This may be surprising when testing apparently "simple" locations like the poles.
Maybe the vec2pix
test would be more robust if it did not compare two different vec2pix
implementations but checked if hp.pix2vec(hp_compat.vec2pix(...))
(and vice versa) ended up close to the original vector again?
@roehling astropy-healpix was originally introduced as a BSD-licensed alternative to healpy (which is GPL); so it IMO makes sense to make sure they both produce the same results. I'd however agree that this does not need to extend beyond FP arithmetic limits.
That's why I proposed the forward-backward round trip through both implementations, which effectively shows that they behave equivalently (up to FP precision).
@roehling, if I understand it correctly, your proposed hp.pix2vec(hp_compat.vec2pix(...))
test will return a vector that's within half a pixel size of the input vector, and "pixel size" is not very nicely defined in Healpix. I'm not sure whether this kind of test would be very informative.
One could try something like hp.vec2pix(hp_compat.pix2vec(pix))==pix
, but that only tests whether the functions are equivalent if provided with pixel centers...
@mreineck Given that the functions are numerically unstable if provided with vectors which are on (or very close to) a pixel border, I see two options:
The Debian package of astropy-healpix got bug report Debian#1026012, that the build time test now fails. The package was version 0.6, but0.7 shows the same behavior. Specifically, the following two tests fail:
This is with
The package was reported to pass the integration testing for Astropy 5.2.