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

Test fails for test_pix2ang and test_ring2nest #39

Closed
cdeil opened this issue Sep 26, 2017 · 4 comments
Closed

Test fails for test_pix2ang and test_ring2nest #39

cdeil opened this issue Sep 26, 2017 · 4 comments
Assignees
Labels
Milestone

Comments

@cdeil
Copy link
Member

cdeil commented Sep 26, 2017

I see two test fails locally. I think they are deterministic (tried two times and got the exact same numbers / fails), and probably precision-related. @astrofrog - Thoughts?

_________________________________________________________________________ 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))

healpix/tests/test_healpy.py:75: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/hypothesis/executors.py:58: in default_new_style_executor
    return function(data)
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/hypothesis/core.py:115: in run
    return test(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

nside_pow = 29, frac = 0.1666666694606345, nest = False, 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)
    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([  1.124984e-06])
E                y: array(1.1235210848771786e-06)

healpix/tests/test_healpy.py:89: AssertionError
-------------------------------------------------------------------------- Hypothesis ---------------------------------------------------------------------------
Falsifying example: test_pix2ang(nside_pow=29, frac=0.1666666694606345, nest=False, lonlat=False)
________________________________________________________________________ test_ring2nest _________________________________________________________________________

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

healpix/tests/test_healpy.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/hypothesis/executors.py:58: in default_new_style_executor
    return function(data)
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/hypothesis/core.py:115: in run
    return test(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

nside_pow = 29, frac = 0.16666666697710755

    @given(nside_pow=integers(0, 29),
           frac=floats(0, 1, allow_nan=False, allow_infinity=False).filter(lambda x: x < 1))
    @settings(max_examples=2000, derandomize=True)
    def test_ring2nest(nside_pow, frac):
        nside = 2 ** nside_pow
        ring = int(frac * 12 * nside ** 2)
        nest1 = hp_compat.ring2nest(nside, ring)
        nest2 = hp.ring2nest(nside, ring)
>       assert nest1 == nest2
E       assert array([192153584101124779]) == 192153584101113855

healpix/tests/test_healpy.py:111: AssertionError
-------------------------------------------------------------------------- Hypothesis ---------------------------------------------------------------------------
Falsifying example: test_ring2nest(nside_pow=29, frac=0.16666666697710755)
============================================================= 2 failed, 260 passed in 6.94 seconds ==============================================================
@cdeil cdeil added the bug label Sep 26, 2017
@cdeil cdeil added this to the 0.1 milestone Sep 26, 2017
@astrofrog
Copy link
Member

Yes, these seem precision-related. The ring2nest one must be an integer precision issue, while the pix2ang one must be related to #34. This are not critical since they happen for very high values of nside, but we should still try and fix them (fixing the first one might actually involve adjusting the test). What's curious is that the derandomize option is still resulting in different cases on different computers.

Anyway, a solution for now would be to lower the maximum value of nside until we sort out these kinds of issues.

@astrofrog
Copy link
Member

What's interesting about these examples is that even if I set hypothesis to run them as known examples I don't see a failure. Very strange!

@astrofrog
Copy link
Member

@cdeil - could you check whether you still get failures with the latest master? I think these should now be fixed.

@cdeil
Copy link
Member Author

cdeil commented Oct 15, 2017

All tests pass for me locally now. Closing this issue.

@cdeil cdeil closed this as completed Oct 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants