Commit 5dd72e31 authored by payno's avatar payno
Browse files

black format

parent b9bad08c
Pipeline #33043 failed with stages
in 3 minutes and 9 seconds
......@@ -474,7 +474,10 @@ class TomoScanBase:
"".format(flat_index)
)
can_process = False
elif self.normed_flats is not None and self.normed_flats[flat_index].ndim != 2:
elif (
self.normed_flats is not None
and self.normed_flats[flat_index].ndim != 2
):
_logger.error(
"cannot make flat field correction, flat should be of "
"dimension 2"
......@@ -492,10 +495,15 @@ class TomoScanBase:
flat_1 = flat_keys[0]
flat_2 = flat_keys[1]
flat_value = self.normed_flats[flat_1] * flat_weights[flat_1] + self.normed_flats[flat_2] * flat_weights[flat_2]
flat_value = (
self.normed_flats[flat_1] * flat_weights[flat_1]
+ self.normed_flats[flat_2] * flat_weights[flat_2]
)
else:
raise ValueError('no more than two flats are expected and'
'at least one shuold be provided')
raise ValueError(
"no more than two flats are expected and"
"at least one shuold be provided"
)
div = flat_value - dark
div[div == 0] = 1
......@@ -531,7 +539,7 @@ class TomoScanBase:
self._flats_weights = self._get_flats_weights()
if self._flats_weights in (None, {}):
_logger.error('Unable to compute flat weights')
_logger.error("Unable to compute flat weights")
darks = self._normed_darks
if darks is not None and len(darks) > 0:
......@@ -572,7 +580,7 @@ class TomoScanBase:
left_pos = flats_indexes[pos - 1]
if pos == 0:
return {flats_indexes[0]: 1.0}
elif pos > len(flats_indexes) -1:
elif pos > len(flats_indexes) - 1:
return {flats_indexes[-1]: 1.0}
else:
right_pos = flats_indexes[pos]
......
......@@ -58,15 +58,15 @@ class TestFlatFieldCorrection(unittest.TestCase):
self._data_urls = {}
projections = {}
file_path = os.path.join(self.data_dir, 'data_file.h5')
file_path = os.path.join(self.data_dir, "data_file.h5")
for i in range(-2, 30):
projections[i] = numpy.random.random(100).reshape((10, 10))
data_path = '/'.join(('data', str(i)))
self._data_urls[i] = DataUrl(file_path=file_path,
data_path=data_path,
scheme='silx')
with h5py.File(file_path, mode='a') as h5s:
data_path = "/".join(("data", str(i)))
self._data_urls[i] = DataUrl(
file_path=file_path, data_path=data_path, scheme="silx"
)
with h5py.File(file_path, mode="a") as h5s:
h5s[data_path] = projections[i]
self.scan.projections = projections
......@@ -93,9 +93,9 @@ class TestFlatFieldCorrection(unittest.TestCase):
for key in ddict1.keys():
self.assertAlmostEqual(ddict1[key], ddict2[key])
assertAlmostEqual(flat_weights[2], {1: 10.0/11.0, 12: 1.0/11.0})
assertAlmostEqual(flat_weights[10], {1: 2.0/11.0, 12: 9.0/11.0})
assertAlmostEqual(flat_weights[18], {12: 3.0/9.0, 21: 6.0/9.0})
assertAlmostEqual(flat_weights[2], {1: 10.0 / 11.0, 12: 1.0 / 11.0})
assertAlmostEqual(flat_weights[10], {1: 2.0 / 11.0, 12: 9.0 / 11.0})
assertAlmostEqual(flat_weights[18], {12: 3.0 / 9.0, 21: 6.0 / 9.0})
def test_flat_field_data_url(self):
"""insure the flat_field is computed. Simple processing test when
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment