@@ -0,0 +1,2227 @@
+import numpy as np%0A%0Afrom .common import Benchmark%0A%0Atry:%0A    from scipy.ndimage import (geometric_transform, affine_transform, rotate,%0A                               zoom, shift, map_coordinates)%0Aexcept ImportError:%0A    pass%0A%0A%0Adef shift_func_2d(c):%0A    return (c%5B0%5D - 0.5, c%5B1%5D - 0.5)%0A%0A%0Adef shift_func_3d(c):%0A    return (c%5B0%5D - 0.5, c%5B1%5D - 0.5, c%5B2%5D - 0.5)%0A%0A%0Aclass NdimageInterpolation(Benchmark):%0A    param_names = %5B'shape', 'order', 'mode'%5D%0A    params = %5B%0A        %5B(64, 64), (512, 512), (2048, 2048), (16, 16, 16), (128, 128, 128)%5D,%0A        %5B0, 1, 3, 5%5D,%0A        %5B'mirror', 'constant'%5D%0A    %5D%0A%0A    def setup(self, shape, order, mode):%0A        rstate = np.random.RandomState(5)%0A        self.x = rstate.standard_normal(shape)%0A        self.matrix_2d = np.asarray(%5B%5B0.8, 0, 1.5%5D,%0A                                     %5B0, 1.2, -5.%5D%5D)%0A        self.matrix_3d = np.asarray(%5B%5B0.8, 0, 0, 1.5%5D,%0A                                     %5B0, 1.2, 0, -5.%5D,%0A                                     %5B0, 0, 1, 0%5D%5D)%0A%0A    def time_affine_transform(self, shape, order, mode):%0A        if self.x.ndim == 2:%0A            matrix = self.matrix_2d%0A        else:%0A            matrix = self.matrix_3d%0A        affine_transform(self.x, matrix, order=order, mode=mode)%0A%0A    def time_rotate(self, shape, order, mode):%0A        rotate(self.x, 15, order=order, mode=mode)%0A%0A    def time_shift(self, shape, order, mode):%0A        shift(self.x, (-2.5,) * self.x.ndim, order=order, mode=mode)%0A%0A    def time_zoom(self, shape, order, mode):%0A        zoom(self.x, (1.3,) * self.x.ndim, order=order, mode=mode)%0A%0A    def time_geometric_transform_mapping(self, shape, order, mode):%0A        if self.x.ndim == 2:%0A            mapping = shift_func_2d%0A        if self.x.ndim == 3:%0A            mapping = shift_func_3d%0A        geometric_transform(self.x, mapping, order=order, mode=mode)%0A%0A    def time_map_coordinates(self, shape, order, mode):%0A        coords = np.meshgrid(*%5Bnp.arange(0, s, 2) + 0.3 for s in self.x.shape%5D)%0A        map_coordinates(self.x, coords, order=order, mode=mode)%0A%0A    def peakmem_rotate(self, shape, order, mode):%0A        rotate(self.x, 15, order=order, mode=mode)%0A%0A    def peakmem_shift(self, shape, order, mode):%0A        shift(self.x, 3, order=order, mode=mode)%0A

add scipy.ndimage.interpolation benchmarks (#12802)