Skip to content

Unstructured linear regridding seems to produce the wrong results on OSX ARM64 #3045

@bouweandela

Description

@bouweandela

When running the tests for the unstructured linear regridder on OSX using an ARM CPU, the values look different than expected (failing run here):

______________ TestUnstructuredLinear.test_regridding[True-None] _______________
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x14691efd0>
lazy = True, units = None
unstructured_grid_cube_2d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding(
        self,
        lazy,
        units,
        unstructured_grid_cube_2d,
        target_grid,
    ):
        """Test regridding."""
        if lazy:
            unstructured_grid_cube_2d.data = (
                unstructured_grid_cube_2d.lazy_data()
            )
        if units:
            unstructured_grid_cube_2d.coord("latitude").convert_units(units)
            unstructured_grid_cube_2d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_2d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_2d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux0") == src_cube.coord("aux0")
        assert not result.coords("aux1")
    
        assert result.shape == (2, 3, 3)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
        print(result.data)
        expected_data = np.ma.masked_invalid(
            [
                [
                    [np.nan, np.nan, np.nan],
                    [
                        2.0820837020874023,
                        2.105347156524658,
                        1.4380426406860352,
                    ],
                    [np.nan, np.nan, np.nan],
                ],
                [
                    [np.nan, np.nan, np.nan],
                    [0.0, 0.0, 0.0],
                    [np.nan, np.nan, np.nan],
                ],
            ],
        )
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 2 / 18 (11.1%)
E       Mismatch at indices:
E        [0, 1, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E        [0, 1, 2]: 1.9905288219451904 (ACTUAL), 1.4380426406860352 (DESIRED)
E       Max absolute difference among violations: 0.55248618
E       Max relative difference among violations: 0.38419318
E        ACTUAL: MaskedArray([[[     inf,      inf,      inf],
E                     [2.203631, 2.105347, 1.990529],
E                     [     inf,      inf,      inf]],...
E        DESIRED: MaskedArray([[[     inf,      inf,      inf],
E                     [2.082084, 2.105347, 1.438043],
E                     [     inf,      inf,      inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:204: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[-- -- --]
  [2.2036306858062744 2.105347156524658 1.9905288219451904]
  [-- -- --]]

 [[-- -- --]
  [0.0 0.0 0.0]
  [-- -- --]]]
_______________ TestUnstructuredLinear.test_regridding[True-rad] _______________
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x14691f110>
lazy = True, units = 'rad'
unstructured_grid_cube_2d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding(
        self,
        lazy,
        units,
        unstructured_grid_cube_2d,
        target_grid,
    ):
        """Test regridding."""
        if lazy:
            unstructured_grid_cube_2d.data = (
                unstructured_grid_cube_2d.lazy_data()
            )
        if units:
            unstructured_grid_cube_2d.coord("latitude").convert_units(units)
            unstructured_grid_cube_2d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_2d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_2d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux0") == src_cube.coord("aux0")
        assert not result.coords("aux1")
    
        assert result.shape == (2, 3, 3)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
        print(result.data)
        expected_data = np.ma.masked_invalid(
            [
                [
                    [np.nan, np.nan, np.nan],
                    [
                        2.0820837020874023,
                        2.105347156524658,
                        1.4380426406860352,
                    ],
                    [np.nan, np.nan, np.nan],
                ],
                [
                    [np.nan, np.nan, np.nan],
                    [0.0, 0.0, 0.0],
                    [np.nan, np.nan, np.nan],
                ],
            ],
        )
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 1 / 18 (5.56%)
E       Mismatch at index:
E        [0, 1, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E       Max absolute difference among violations: 0.12154698
E       Max relative difference among violations: 0.05837757
E        ACTUAL: MaskedArray([[[     inf,      inf,      inf],
E                     [2.203631, 2.105347, 1.438043],
E                     [     inf,      inf,      inf]],...
E        DESIRED: MaskedArray([[[     inf,      inf,      inf],
E                     [2.082084, 2.105347, 1.438043],
E                     [     inf,      inf,      inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:204: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[-- -- --]
  [2.2036306858062744 2.105347156524658 1.4380426406860352]
  [-- -- --]]

 [[-- -- --]
  [0.0 0.0 0.0]
  [-- -- --]]]
______________ TestUnstructuredLinear.test_regridding[False-None] ______________
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x146e77490>
lazy = False, units = None
unstructured_grid_cube_2d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding(
        self,
        lazy,
        units,
        unstructured_grid_cube_2d,
        target_grid,
    ):
        """Test regridding."""
        if lazy:
            unstructured_grid_cube_2d.data = (
                unstructured_grid_cube_2d.lazy_data()
            )
        if units:
            unstructured_grid_cube_2d.coord("latitude").convert_units(units)
            unstructured_grid_cube_2d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_2d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_2d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux0") == src_cube.coord("aux0")
        assert not result.coords("aux1")
    
        assert result.shape == (2, 3, 3)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
        print(result.data)
        expected_data = np.ma.masked_invalid(
            [
                [
                    [np.nan, np.nan, np.nan],
                    [
                        2.0820837020874023,
                        2.105347156524658,
                        1.4380426406860352,
                    ],
                    [np.nan, np.nan, np.nan],
                ],
                [
                    [np.nan, np.nan, np.nan],
                    [0.0, 0.0, 0.0],
                    [np.nan, np.nan, np.nan],
                ],
            ],
        )
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 2 / 18 (11.1%)
E       Mismatch at indices:
E        [0, 1, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E        [0, 1, 2]: 1.9905288219451904 (ACTUAL), 1.4380426406860352 (DESIRED)
E       Max absolute difference among violations: 0.55248618
E       Max relative difference among violations: 0.38419318
E        ACTUAL: MaskedArray([[[     inf,      inf,      inf],
E                     [2.203631, 2.105347, 1.990529],
E                     [     inf,      inf,      inf]],...
E        DESIRED: MaskedArray([[[     inf,      inf,      inf],
E                     [2.082084, 2.105347, 1.438043],
E                     [     inf,      inf,      inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:204: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[-- -- --]
  [2.2036306858062744 2.105347156524658 1.9905288219451904]
  [-- -- --]]

 [[-- -- --]
  [0.0 0.0 0.0]
  [-- -- --]]]
______________ TestUnstructuredLinear.test_regridding[False-rad] _______________
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x146e76ea0>
lazy = False, units = 'rad'
unstructured_grid_cube_2d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding(
        self,
        lazy,
        units,
        unstructured_grid_cube_2d,
        target_grid,
    ):
        """Test regridding."""
        if lazy:
            unstructured_grid_cube_2d.data = (
                unstructured_grid_cube_2d.lazy_data()
            )
        if units:
            unstructured_grid_cube_2d.coord("latitude").convert_units(units)
            unstructured_grid_cube_2d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_2d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_2d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux0") == src_cube.coord("aux0")
        assert not result.coords("aux1")
    
        assert result.shape == (2, 3, 3)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
        print(result.data)
        expected_data = np.ma.masked_invalid(
            [
                [
                    [np.nan, np.nan, np.nan],
                    [
                        2.0820837020874023,
                        2.105347156524658,
                        1.4380426406860352,
                    ],
                    [np.nan, np.nan, np.nan],
                ],
                [
                    [np.nan, np.nan, np.nan],
                    [0.0, 0.0, 0.0],
                    [np.nan, np.nan, np.nan],
                ],
            ],
        )
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 1 / 18 (5.56%)
E       Mismatch at index:
E        [0, 1, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E       Max absolute difference among violations: 0.12154698
E       Max relative difference among violations: 0.05837757
E        ACTUAL: MaskedArray([[[     inf,      inf,      inf],
E                     [2.203631, 2.105347, 1.438043],
E                     [     inf,      inf,      inf]],...
E        DESIRED: MaskedArray([[[     inf,      inf,      inf],
E                     [2.082084, 2.105347, 1.438043],
E                     [     inf,      inf,      inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:204: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[-- -- --]
  [2.2036306858062744 2.105347156524658 1.4380426406860352]
  [-- -- --]]

 [[-- -- --]
  [0.0 0.0 0.0]
  [-- -- --]]]
____ TestUnstructuredLinear.test_regridding_mask_and_transposed[True-None] _____
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x146aa31d0>
units = None, lazy = True
unstructured_grid_cube_3d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4; altitude: 2)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding_mask_and_transposed(
        self,
        units,
        lazy,
        unstructured_grid_cube_3d,
        target_grid,
    ):
        """Test regridding."""
        # Test that regridding also works if lat/lon are not rightmost
        # dimensions
        unstructured_grid_cube_3d.transpose([0, 2, 1])
        if lazy:
            unstructured_grid_cube_3d.data = (
                unstructured_grid_cube_3d.lazy_data()
            )
        if units:
            unstructured_grid_cube_3d.coord("latitude").convert_units(units)
            unstructured_grid_cube_3d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_3d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_3d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("altitude") == src_cube.coord("altitude")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux") == src_cube.coord("aux")
    
        assert result.shape == (2, 3, 3, 2)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
    
        expected_data = np.ma.masked_all((2, 3, 3, 2), dtype=np.float32)
        expected_data[0, 1, :, :] = [
            [2.0820837020874023, 6.082083702087402],
            [2.105347156524658, 6.105347156524658],
            [1.4380426406860352, 5.438042640686035],
        ]
        print(result.data)
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 26 / 36 (72.2%)
E       Mismatch at indices:
E        [0, 1, 0, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E        [0, 1, 0, 1]: 6.203630447387695 (ACTUAL), 6.082083702087402 (DESIRED)
E        [0, 1, 2, 0]: 1.9905288219451904 (ACTUAL), 1.4380426406860352 (DESIRED)
E        [0, 1, 2, 1]: 5.990528583526611 (ACTUAL), 5.438042640686035 (DESIRED)
E       Max absolute difference among violations: 0.5524862
E       Max relative difference among violations: 0.38419318
E        ACTUAL: MaskedArray([[[[     inf,      inf],
E                      [     inf,      inf],
E                      [     inf,      inf]],...
E        DESIRED: MaskedArray([[[[      inf,       inf],
E                      [      inf,       inf],
E                      [      inf,       inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:253: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[[-- --]
   [-- --]
   [-- --]]

  [[2.2036306858062744 6.203630447387695]
   [2.105347156524658 6.105347156524658]
   [1.9905288219451904 5.990528583526611]]

  [[-- --]
   [-- --]
   [-- --]]]


 [[[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]]]
_____ TestUnstructuredLinear.test_regridding_mask_and_transposed[True-rad] _____
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x146a145a0>
units = 'rad', lazy = True
unstructured_grid_cube_3d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4; altitude: 2)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding_mask_and_transposed(
        self,
        units,
        lazy,
        unstructured_grid_cube_3d,
        target_grid,
    ):
        """Test regridding."""
        # Test that regridding also works if lat/lon are not rightmost
        # dimensions
        unstructured_grid_cube_3d.transpose([0, 2, 1])
        if lazy:
            unstructured_grid_cube_3d.data = (
                unstructured_grid_cube_3d.lazy_data()
            )
        if units:
            unstructured_grid_cube_3d.coord("latitude").convert_units(units)
            unstructured_grid_cube_3d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_3d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_3d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("altitude") == src_cube.coord("altitude")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux") == src_cube.coord("aux")
    
        assert result.shape == (2, 3, 3, 2)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
    
        expected_data = np.ma.masked_all((2, 3, 3, 2), dtype=np.float32)
        expected_data[0, 1, :, :] = [
            [2.0820837020874023, 6.082083702087402],
            [2.105347156524658, 6.105347156524658],
            [1.4380426406860352, 5.438042640686035],
        ]
        print(result.data)
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 24 / 36 (66.7%)
E       Mismatch at indices:
E        [0, 1, 0, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E        [0, 1, 0, 1]: 6.203630447387695 (ACTUAL), 6.082083702087402 (DESIRED)
E       Max absolute difference among violations: 0.12154698
E       Max relative difference among violations: 0.05837757
E        ACTUAL: MaskedArray([[[[     inf,      inf],
E                      [     inf,      inf],
E                      [     inf,      inf]],...
E        DESIRED: MaskedArray([[[[      inf,       inf],
E                      [      inf,       inf],
E                      [      inf,       inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:253: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[[-- --]
   [-- --]
   [-- --]]

  [[2.2036306858062744 6.203630447387695]
   [2.105347156524658 6.105347156524658]
   [1.4380426406860352 5.438042640686035]]

  [[-- --]
   [-- --]
   [-- --]]]


 [[[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]]]
____ TestUnstructuredLinear.test_regridding_mask_and_transposed[False-None] ____
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x146a146b0>
units = None, lazy = False
unstructured_grid_cube_3d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4; altitude: 2)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding_mask_and_transposed(
        self,
        units,
        lazy,
        unstructured_grid_cube_3d,
        target_grid,
    ):
        """Test regridding."""
        # Test that regridding also works if lat/lon are not rightmost
        # dimensions
        unstructured_grid_cube_3d.transpose([0, 2, 1])
        if lazy:
            unstructured_grid_cube_3d.data = (
                unstructured_grid_cube_3d.lazy_data()
            )
        if units:
            unstructured_grid_cube_3d.coord("latitude").convert_units(units)
            unstructured_grid_cube_3d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_3d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_3d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("altitude") == src_cube.coord("altitude")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux") == src_cube.coord("aux")
    
        assert result.shape == (2, 3, 3, 2)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
    
        expected_data = np.ma.masked_all((2, 3, 3, 2), dtype=np.float32)
        expected_data[0, 1, :, :] = [
            [2.0820837020874023, 6.082083702087402],
            [2.105347156524658, 6.105347156524658],
            [1.4380426406860352, 5.438042640686035],
        ]
        print(result.data)
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 31 / 36 (86.1%)
E       Mismatch at indices:
E        [0, 1, 0, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E        [0, 1, 0, 1]: 6.203630447387695 (ACTUAL), 6.082083702087402 (DESIRED)
E        [0, 1, 2, 0]: 1.9905288219451904 (ACTUAL), 1.4380426406860352 (DESIRED)
E        [0, 1, 2, 1]: 5.990528583526611 (ACTUAL), 5.438042640686035 (DESIRED)
E       Max absolute difference among violations: 0.5524862
E       Max relative difference among violations: 0.38419318
E        ACTUAL: MaskedArray([[[[     inf,      inf],
E                      [     inf,      inf],
E                      [     inf,      inf]],...
E        DESIRED: MaskedArray([[[[          inf,           inf],
E                      [          inf,           inf],
E                      [          inf,           inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:253: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[[-- --]
   [-- --]
   [-- --]]

  [[2.2036306858062744 6.203630447387695]
   [2.105347156524658 6.105347156524658]
   [1.9905288219451904 5.990528583526611]]

  [[-- --]
   [-- --]
   [-- --]]]


 [[[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]]]
____ TestUnstructuredLinear.test_regridding_mask_and_transposed[False-rad] _____
[gw1] darwin -- Python 3.14.4 /Users/runner/work/ESMValCore/ESMValCore/.pixi/envs/default/bin/python3.14

self = <tests.integration.preprocessor._regrid.test_regrid_unstructured.TestUnstructuredLinear object at 0x14735a150>
units = 'rad', lazy = False
unstructured_grid_cube_3d = <iris 'Cube' of air_temperature / (K) (time: 2; -- : 4; altitude: 2)>
target_grid = <iris 'Cube' of unknown / (unknown) (latitude: 3; longitude: 3)>

    @pytest.mark.parametrize("units", [None, "rad"])
    @pytest.mark.parametrize("lazy", [True, False])
    def test_regridding_mask_and_transposed(
        self,
        units,
        lazy,
        unstructured_grid_cube_3d,
        target_grid,
    ):
        """Test regridding."""
        # Test that regridding also works if lat/lon are not rightmost
        # dimensions
        unstructured_grid_cube_3d.transpose([0, 2, 1])
        if lazy:
            unstructured_grid_cube_3d.data = (
                unstructured_grid_cube_3d.lazy_data()
            )
        if units:
            unstructured_grid_cube_3d.coord("latitude").convert_units(units)
            unstructured_grid_cube_3d.coord("longitude").convert_units(units)
            target_grid.coord("latitude").convert_units(units)
            target_grid.coord("longitude").convert_units(units)
        src_cube = unstructured_grid_cube_3d.copy()
    
        result = src_cube.regrid(target_grid, UnstructuredLinear())
    
        assert src_cube == unstructured_grid_cube_3d
        assert result.metadata == src_cube.metadata
    
        assert result.coord("time") == src_cube.coord("time")
        assert result.coord("altitude") == src_cube.coord("altitude")
        assert result.coord("latitude") == target_grid.coord("latitude")
        assert result.coord("longitude") == target_grid.coord("longitude")
        assert result.coord("aux") == src_cube.coord("aux")
    
        assert result.shape == (2, 3, 3, 2)
        assert result.has_lazy_data() is lazy
        assert result.dtype == np.float32
    
        expected_data = np.ma.masked_all((2, 3, 3, 2), dtype=np.float32)
        expected_data[0, 1, :, :] = [
            [2.0820837020874023, 6.082083702087402],
            [2.105347156524658, 6.105347156524658],
            [1.4380426406860352, 5.438042640686035],
        ]
        print(result.data)
>       np.testing.assert_allclose(result.data, expected_data)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 28 / 36 (77.8%)
E       Mismatch at indices:
E        [0, 1, 0, 0]: 2.2036306858062744 (ACTUAL), 2.0820837020874023 (DESIRED)
E        [0, 1, 0, 1]: 6.203630447387695 (ACTUAL), 6.082083702087402 (DESIRED)
E       Max absolute difference among violations: 0.12154698
E       Max relative difference among violations: 0.05837757
E        ACTUAL: MaskedArray([[[[     inf,      inf],
E                      [     inf,      inf],
E                      [     inf,      inf]],...
E        DESIRED: MaskedArray([[[[          inf,           inf],
E                      [          inf,           inf],
E                      [          inf,           inf]],...

tests/integration/preprocessor/_regrid/test_regrid_unstructured.py:253: AssertionError
----------------------------- Captured stdout call -----------------------------
[[[[-- --]
   [-- --]
   [-- --]]

  [[2.2036306858062744 6.203630447387695]
   [2.105347156524658 6.105347156524658]
   [1.4380426406860352 5.438042640686035]]

  [[-- --]
   [-- --]
   [-- --]]]


 [[[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]

  [[-- --]
   [-- --]
   [-- --]]]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions