astropy / astropy-healpix

BSD-licensed HEALPix for Astropy - maintained by @astrofrog and @lpsinger
https://astropy-healpix.readthedocs.io
BSD 3-Clause "New" or "Revised" License
52 stars 22 forks source link

pix2ang fails on ppc64el #80

Closed lpsinger closed 6 years ago

lpsinger commented 6 years ago

See the Debian build log. Excerpt here:

=================================== FAILURES ===================================
_________________________________ test_pix2ang _________________________________

    @given(nside_pow=integers(0, 29), nest=booleans(), lonlat=booleans(),
>          frac=floats(0, 1, allow_nan=False, allow_infinity=False).filter(lambda x: x < 1))

astropy_healpix/tests/test_healpy.py:100: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3/dist-packages/hypothesis/core.py:579: in execute
    result = self.test_runner(data, run)
/usr/lib/python3/dist-packages/hypothesis/executors.py:58: in default_new_style_executor
    return function(data)
/usr/lib/python3/dist-packages/hypothesis/core.py:571: in run
    return test(*args, **kwargs)
astropy_healpix/tests/test_healpy.py:100: in test_pix2ang
    frac=floats(0, 1, allow_nan=False, allow_infinity=False).filter(lambda x: x < 1))
/usr/lib/python3/dist-packages/hypothesis/core.py:518: in test
    result = self.test(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

nside_pow = 27, frac = 0.6666666666666666, nest = True, lonlat = False

    @given(nside_pow=integers(0, 29), nest=booleans(), lonlat=booleans(),
           frac=floats(0, 1, allow_nan=False, allow_infinity=False).filter(lambda x: x < 1))
    @settings(max_examples=2000, derandomize=True)
    @example(nside_pow=29, frac=0.1666666694606345, nest=False, lonlat=False)
    def test_pix2ang(nside_pow, frac, nest, lonlat):
        nside = 2 ** nside_pow
        ipix = int(frac * 12 * nside ** 2)
        theta1, phi1 = hp_compat.pix2ang(nside, ipix, nest=nest, lonlat=lonlat)
        theta2, phi2 = hp.pix2ang(nside, ipix, nest=nest, lonlat=lonlat)
        if lonlat:
            assert_allclose(phi1, phi2, atol=1e-8)
            if abs(phi1) < 90:
                assert_allclose(theta1, theta2, atol=1e-10)
        else:
            assert_allclose(theta1, theta2, atol=1e-8)
            if theta1 > 0:
>               assert_allclose(phi1, phi2, atol=1e-10)
E               AssertionError: 
E               Not equal to tolerance rtol=1e-07, atol=1e-10
E               
E               (mismatch 100.0%)
E                x: array(0.)
E                y: array(0.785398)

astropy_healpix/tests/test_healpy.py:115: AssertionError
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_pix2ang(nside_pow=27, frac=0.6666666666666666, nest=True, lonlat=False)
==================== 1 failed, 293 passed in 72.53 seconds =====================
lpsinger commented 6 years ago

Hmm. Now it passed. Is this test at all non-deterministic?

astrofrog commented 6 years ago

The hypothesis tests are non-deterministic due to the way hypothesis works but you could consider adding the failing example test_pix2ang(nside_pow=27, frac=0.6666666666666666, nest=True, lonlat=False) as a fixed example to try. This is how to set a fixed example: https://github.com/astropy/astropy-healpix/blob/master/astropy_healpix/tests/test_healpy.py#L102 (and I think frac should probably be set to 2/3 instead of 0.6666666...)

astrofrog commented 6 years ago

This is not related to PPC: https://github.com/astropy/astropy-healpix/pull/84

lpsinger commented 6 years ago

This is not related to PPC: #84

Good catch!