def test_order_0_warp_dtype(dtype): img = _convert(astronaut()[:10, :10, 0], dtype) assert resize(img, (12, 12), order=0).dtype == dtype assert rescale(img, 0.5, order=0).dtype == dtype assert rotate(img, 45, order=0).dtype == dtype assert warp_polar(img, order=0).dtype == dtype assert swirl(img, order=0).dtype == dtype
def test_swirl(): image = img_as_float(checkerboard()) swirl_params = {'radius': 80, 'rotation': 0, 'order': 2, 'mode': 'reflect'} with expected_warnings(['Bi-quadratic.*bug']): swirled = swirl(image, strength=10, **swirl_params) unswirled = swirl(swirled, strength=-10, **swirl_params) assert np.mean(np.abs(image - unswirled)) < 0.01 swirl_params.pop('mode') with expected_warnings(['Bi-quadratic.*bug']): swirled = swirl(image, strength=10, **swirl_params) unswirled = swirl(swirled, strength=-10, **swirl_params) assert np.mean(np.abs(image[1:-1, 1:-1] - unswirled[1:-1, 1:-1])) < 0.01
def test_nonzero_order_warp_dtype(dtype, order): img = _convert(astronaut()[:10, :10, 0], dtype) float_dtype = _supported_float_type(dtype) assert resize(img, (12, 12), order=order).dtype == float_dtype assert rescale(img, 0.5, order=order).dtype == float_dtype assert rotate(img, 45, order=order).dtype == float_dtype assert warp_polar(img, order=order).dtype == float_dtype assert swirl(img, order=order).dtype == float_dtype