TST: add half integer test case for map_coordinates
@@ -117,6 +117,29 @@ class TestMapCoordinates:
return out
+@testing.parameterize(*testing.product({
+ 'order': [0, 1, 2, 3, 4, 5],
+ 'mode': ['constant', 'nearest', 'mirror'] + scipy16_modes,
+}))
+@testing.gpu
+@testing.with_requires('scipy')
+class TestMapCoordinatesHalfInteger:
+
+ def _map_coordinates(self, xp, scp, a, coordinates):
+ _conditional_scipy_version_skip(self.mode, self.order)
+ map_coordinates = scp.ndimage.map_coordinates
+ return map_coordinates(a, coordinates, None, self.order, self.mode)
+
+ @testing.for_float_dtypes(no_float16=True)
+ @testing.numpy_cupy_allclose(atol=1e-4, scipy_name='scp')
+ def test_map_coordinates_float(self, xp, scp, dtype):
+ # Half integer coordinate rounding test case from:
+ # https://github.com/cupy/cupy/issues/4550
+ a = testing.shaped_arange((4, 3), xp, dtype)
+ coordinates = xp.array([[0.5, 2], [0.5, 1]])
+ return self._map_coordinates(xp, scp, a, coordinates)
+
+
@testing.parameterize(*testing.product({
'matrix_shape': [(2,), (2, 2), (2, 3), (3, 3)],
'offset': [0.3, [-1.3, 1.3]],
