Skip to content

Commit

Permalink
Fix tests after removing tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
hrobarts committed Sep 23, 2024
1 parent 3126cc1 commit e8423bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Wrappers/Python/cil/processors/FluxNormaliser.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ def check_input(self, dataset):

self.flux = numpy.mean(dataset.array[tuple(slc)], axis=tuple(axes))

dataset_range = dataset.max(axis=tuple(axes)) - dataset.min(axis=tuple(axes))
dataset_range = numpy.max(dataset.array, axis=tuple(axes)) - numpy.min(dataset.array, axis=tuple(axes))

if (numpy.mean(self.flux) > dataset.mean()):
if numpy.mean(self.flux/dataset_range.array) < 0.9:
if numpy.mean(self.flux/dataset_range) < 0.9:
log.warning('Warning: mean value in selected roi is more than 10 percent of data range - may not represent the background')
else:
if numpy.mean(self.flux/dataset_range.array) > 0.1:
if numpy.mean(self.flux/dataset_range) > 0.1:
log.warning('Warning: mean value in selected roi is more than 10 percent of data range - may not represent the background')

self.roi_slice = slc
Expand Down
12 changes: 6 additions & 6 deletions Wrappers/Python/test/test_DataProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3110,15 +3110,15 @@ def error_message(self,processor, test_parameter):
def test_init(self):
# test default values are initialised
processor = FluxNormaliser()
test_parameter = ['flux','roi','norm_value', 'tolerance']
test_value = [None, None, None, 1e-5]
test_parameter = ['flux','roi','norm_value']
test_value = [None, None, None]

for i in numpy.arange(len(test_value)):
self.assertEqual(getattr(processor, test_parameter[i]), test_value[i], msg=self.error_message(processor, test_parameter[i]))

# test non-default values are initialised
processor = FluxNormaliser(1,2,3,4)
test_value = [1, 2, 3, 4]
processor = FluxNormaliser(1,2,3)
test_value = [1, 2, 3]
for i in numpy.arange(len(test_value)):
self.assertEqual(getattr(processor, test_parameter[i]), test_value[i], msg=self.error_message(processor, test_parameter[i]))

Expand Down Expand Up @@ -3207,13 +3207,13 @@ def test_FluxNormaliser(self):
numpy.testing.assert_allclose(data_norm.array, 0.5*self.data_cone.array)

#Test flux array with no norm_value
processor = FluxNormaliser(flux=numpy.arange(1,2,(2-1)/(data.get_dimension_size('angle'))))
processor = FluxNormaliser(flux=numpy.arange(1,2,(2-1)/(self.data_cone.get_dimension_size('angle'))))
processor.set_input(self.data_cone)
data_norm = processor.get_output()
numpy.testing.assert_allclose(data_norm.array, self.data_cone.array)

#Test flux array with norm_value
processor = FluxNormaliser(flux=numpy.arange(1,2,(2-1)/(data.get_dimension_size('angle'))), norm_value=5)
processor = FluxNormaliser(flux=numpy.arange(1,2,(2-1)/(self.data_cone.get_dimension_size('angle'))), norm_value=5)
processor.set_input(self.data_cone)
data_norm = processor.get_output()
numpy.testing.assert_allclose(data_norm.array, 0.5*self.data_cone.array)
Expand Down

0 comments on commit e8423bb

Please sign in to comment.