def test_alignstack_calls_filterfn(self):
     filterfn = Mock()
     filterfn.side_effect = lambda x: x
     im = test_image()
     up = _up(im)
     down = _down(im)
     alignstack([im, up, down],
                shiftfn=RegisterTranslation(),
                filterfn=filterfn)
     for i, t in enumerate([im, up, down]):
         self.assertIs(filterfn.call_args_list[i][0][0], t)
 def test_image_shift(self):
     im = test_image()
     calculate_shift = RegisterTranslation()
     s = calculate_shift(im, _up(im))
     np.testing.assert_equal(s, (1, 0))
     s = calculate_shift(im, _down(im))
     np.testing.assert_equal(s, (-1, 0))
     s = calculate_shift(im, _left(im))
     np.testing.assert_equal(s, (0, 1))
     s = calculate_shift(im, _right(im))
     np.testing.assert_equal(s, (0, -1))
     s = calculate_shift(im, _left(_left(im)))
     np.testing.assert_equal(s, (0, 2))
 def test_alignstack(self):
     im = test_image()
     _, aligned = alignstack(
         [im, _up(im), _down(im), _right(im)],
         shiftfn=RegisterTranslation())
     self.assertEqual(aligned.shape, (4, 5, 7))