Skip to content

Commit

Permalink
yapf and ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSullivan7 committed Aug 14, 2024
1 parent 6b2086e commit 6b17527
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mantidimaging/gui/windows/live_viewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def __init__(self, image_list: list[Image_Data], create_delayed_array: bool = Tr
lazy_arrays = [dask.array.from_delayed(x, shape=sample.shape, dtype=sample.dtype) for x in arrays]
self.delayed_stack = dask.array.stack(lazy_arrays)
else:
raise NotImplementedError(f"DaskImageDataStack does not support image with extension {image_list[0].image_path.suffix.lower()}")
raise NotImplementedError(f"DaskImageDataStack does not support image with extension "
f"{image_list[0].image_path.suffix.lower()}")

@property
def shape(self):
Expand Down
10 changes: 7 additions & 3 deletions mantidimaging/gui/windows/live_viewer/test/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def test_WHEN_sub_directory_change_THEN_images_emitted(self, _mock_time):

class DaskImageDataStackTest(unittest.TestCase):

def setUp(self):
self.test_array = np.array([1, 3, 5, 12, 15])

def _get_fake_data(self, ext: str):
file_list = [Path(f"abc_{i:06d}" + ext) for i in range(5)]
with mock.patch("mantidimaging.gui.windows.live_viewer.model.Path.stat"):
Expand Down Expand Up @@ -202,7 +205,7 @@ def test_WHEN_tif_file_THEN_dask_image_imread_called(self, mock_imread):
@mock.patch("mantidimaging.gui.windows.live_viewer.model.dask.delayed")
@mock.patch("mantidimaging.gui.windows.live_viewer.model.DaskImageDataStack.get_fits_sample")
def test_WHEN_fits_file_THEN_dask_delayed_called(self, mock_fits_sample, mock_dask_delayed):
mock_fits_sample.return_value = np.random.random(5)
mock_fits_sample.return_value = self.test_array
image_data_list, _, _ = self._get_fake_data('.fits')
calls = [mock.call()(image.image_path) for image in image_data_list]
with mock.patch("mantidimaging.gui.windows.live_viewer.model.fits.open"):
Expand All @@ -221,8 +224,9 @@ def test_WHEN_unsupported_file_THEN_raises_error(self, mock_delayed_arrays):
@mock.patch("mantidimaging.gui.windows.live_viewer.model.dask.array.from_delayed")
@mock.patch("mantidimaging.gui.windows.live_viewer.model.dask.delayed")
@mock.patch("mantidimaging.gui.windows.live_viewer.model.DaskImageDataStack.get_fits_sample")
def test_WHEN_supported_file_THEN_no_error_raised(self, file_ext, mock_fits_sample, _, mock_from_delayed, mock_delayed_arrays):
mock_fits_sample.return_value = np.random.random(5)
def test_WHEN_supported_file_THEN_no_error_raised(self, file_ext, mock_fits_sample, _, mock_from_delayed,
mock_delayed_arrays):
mock_fits_sample.return_value = self.test_array
image_data_list, fake_data_array_list, _ = self._get_fake_data(file_ext)
mock_delayed_arrays.return_value = fake_data_array_list
mock_from_delayed.return_value = fake_data_array_list
Expand Down

0 comments on commit 6b17527

Please sign in to comment.