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_reproject_healpix_to_image_footprint failures on Debian with ARM (and other) CPUs #414

Closed
olebole opened this issue Nov 27, 2023 · 6 comments

Comments

@olebole
Copy link
Member

olebole commented Nov 27, 2023

On the Debian architectures with ARM (32+64 bit), RISCv64, all test_reproject_healpix_to_image_footprint(…, 'nearest-neighbor') test fail:

_ test_reproject_healpix_to_image_footprint[1-True-C-C-dtype1-nearest-neighbor] _

nside = 1, nested = True, healpix_system = 'C', image_system = 'C'
dtype = dtype('uint8'), order = 'nearest-neighbor'

    @pytest.mark.parametrize(
        "nside,nested,healpix_system,image_system,dtype,order",
        itertools.product(
            [1, 2, 4, 8, 16, 32, 64],
            [True, False],
            "C",
            "C",
            ALL_DTYPES,
            ["bilinear", "nearest-neighbor"],
        ),
    )
    def test_reproject_healpix_to_image_footprint(
        nside, nested, healpix_system, image_system, dtype, order
    ):
        """Test that HEALPix->WCS conversion correctly flags pixels that do not
        have valid WCS coordinates."""
    
        npix = nside_to_npix(nside)
        healpix_data = np.random.uniform(size=npix).astype(dtype)
    
        reference_header = get_reference_header(overscan=2, oversample=2, nside=nside)
    
        wcs_out = WCS(reference_header)
        shape_out = reference_header["NAXIS2"], reference_header["NAXIS1"]
    
        image_data, footprint = reproject_from_healpix(
            (healpix_data, healpix_system),
            wcs_out,
            shape_out=shape_out,
            order=order,
            nested=nested,
        )
    
        if order == "bilinear":
            expected_footprint = ~np.isnan(image_data)
        else:
            coord_system_in = parse_coord_system(healpix_system)
            yinds, xinds = np.indices(shape_out)
            world_in = wcs_out.pixel_to_world(xinds, yinds).transform_to(coord_system_in)
            world_in_unitsph = world_in.represent_as("unitspherical")
            lon_in, lat_in = world_in_unitsph.lon, world_in_unitsph.lat
            expected_footprint = ~(np.isnan(lon_in) | np.isnan(lat_in))
    
>       np.testing.assert_array_equal(footprint, expected_footprint)

reproject/healpix/tests/test_healpix.py:86: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<built-in function eq>, array([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
        1., 1., 1., 1...e,
        False, False, False, False, False, False, False, False, False,
        False, False, False, False, False]]))
kwds = {'err_msg': '', 'header': 'Arrays are not equal', 'strict': False, 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Arrays are not equal
E           
E           Mismatched elements: 359 / 512 (70.1%)
E           Max absolute difference: 1.
E           Max relative difference: 0.
E            x: array([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
E                   1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
E                  [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,...
E            y: array([[False, False, False, False, False, False, False, False, False,
E                   False, False, False, False, False, False, False, False, False,
E                   False, False, False, False, False, False, False, False, False,...

/usr/lib/python3.11/contextlib.py:81: AssertionError

The ones with order='bilinear' pass.
Full build log for amd64.
In Intel (amd64, i386), PowerPC, s390x, all tests pass.

Environment:

  • Python 3.11.6
  • Numpy 1.24.2
  • Scipy: 1.10.1
  • Astropy 5.3.4
  • Astropy-healpix 0.6
@astrofrog
Copy link
Member

astrofrog commented Dec 7, 2023

@lpsinger - I also see something similar when I run the tests locally on M1 Mac (though not on Mac in the CI). It looks like in these cases, the following:

        with np.errstate(invalid="ignore"):
            ipix = hp.lonlat_to_healpix(lon_in, lat_in)

returns an array that has values in the invalid region that are not actually set to -1 but instead to e.g. 8 in the following example:

Screenshot 2023-12-07 at 16 33 20

Do you have any ideas why this would be platform-dependent?

@lpsinger
Copy link
Contributor

lpsinger commented Dec 7, 2023

@astrofrog
Copy link
Member

@lpsinger
Copy link
Contributor

@olebole, we think that astropy/astropy-healpix#208 may have fixed this. We'll roll another release of astropy-healpix shortly.

@lpsinger
Copy link
Contributor

@olebole, we think that this should be fixed now if you updated to astropy-healpix 1.0.1.

@olebole
Copy link
Member Author

olebole commented Dec 18, 2023

Yes, I can confirm this. After uploading healpix 1.0.1, the reproject tests on all platforms pass.

@olebole olebole closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants