def counts(self) -> Counts: counts = numpy.zeros(len(self._data[IMATLogColumn.COUNTS_BEFORE])) for i, [before, after] in enumerate( zip(self._data[IMATLogColumn.COUNTS_BEFORE], self._data[IMATLogColumn.COUNTS_AFTER])): # clips the string before the count number counts[i] = float(after) - float(before) return Counts(counts)
def test_execute(): images = generate_images() images._log_file = mock.Mock() images._log_file.counts = mock.Mock( return_value=Counts(np.sin(np.linspace(0, 1, images.num_projections)))) original = images.copy() MonitorNormalisation.filter_func(images) images._log_file.counts.assert_called_once() assert_not_equals(original.data, images.data)
def test_execute2(): """ Test that the counts are correctly divided by the value at counts[0]. In this test that will make all the counts equal to 1, and the data will remain unchanged """ images = generate_images() images._log_file = mock.Mock() images._log_file.counts = mock.Mock( return_value=Counts(np.full((10, ), 10))) original = images.copy() MonitorNormalisation.filter_func(images) images._log_file.counts.assert_called_once() npt.assert_equal(original.data, images.data)
def test_one_projection(): images = generate_images((1, 1, 1)) images._log_file = mock.Mock() images._log_file.counts = mock.Mock( return_value=Counts(np.sin(np.linspace(0, 1, images.num_projections)))) npt.assert_raises(RuntimeError, MonitorNormalisation.filter_func, images)