def test_interpolation_order(self): im = np.arange(0, 100).reshape((10, 10)) x, y = 2.5, -3.5 im_shift0 = pst._shift_single_frame( im=im, shift_x=x, shift_y=y, interpolation_order=0 ) im_shift1 = pst._shift_single_frame( im=im, shift_x=x, shift_y=y, interpolation_order=1 ) im_shift2 = pst._shift_single_frame( im=im, shift_x=x, shift_y=y, interpolation_order=2 ) assert not (im_shift0 == im_shift1).all() assert not (im_shift1 == im_shift2).all() assert not (im_shift0 == im_shift2).all()
def test_two_half_shift(self, x, y): im = np.zeros((20, 20)) x0, y0 = 10, 12 im[x0, y0] = 1 # Note that the shifts are switched when calling the function, # to stay consistent with the HyperSpy axis ordering im_shift = pst._shift_single_frame(im=im, shift_x=y, shift_y=x) assert im_shift[x0 - int(x), y0 - int(y)] == 0.25 assert im_shift.max() == 0.25 assert im_shift.sum() == 1
def test_simple_shift(self, x, y): im = np.zeros((20, 20)) x0, y0 = 10, 12 im[x0, y0] = 1 # Note that the shifts are switched when calling the function, # to stay consistent with the HyperSpy axis ordering im_shift = pst._shift_single_frame(im=im, shift_x=y, shift_y=x) assert im_shift[x0 - x, y0 - y] == 1 assert im_shift.sum() == 1 im_shift[x0 - x, y0 - y] = 0 assert (im_shift == 0.0).all()