def test_length(self): """ Test that shifts yielded by itrack_peak are as numerous as the number of input pictures """ images = [np.random.random(size=(4, 4)) for _ in range(20)] shifts = list( itrack_peak(images, row_slice=np.s_[:], col_slice=np.s_[:])) self.assertEqual(len(shifts), len(images))
def test_trivial(self): """ Test that shift is identically zero for images that are identical """ # Array prototype is just zeros # with a 'peak' in the center prototype = np.zeros(shape=(17, 17)) prototype[9, 9] = 10 images = [np.array(prototype) for _ in range(20)] shifts = itrack_peak(images, row_slice=np.s_[:], col_slice=np.s_[:]) for shift in shifts: self.assertTrue(np.allclose(shift, (0.0, 0.0)))