From 6b1752732ec60836ff24625d1ea4a87fcf3e9542 Mon Sep 17 00:00:00 2001 From: Mike Sullivan Date: Wed, 14 Aug 2024 17:31:45 +0100 Subject: [PATCH] yapf and ruff fixes --- mantidimaging/gui/windows/live_viewer/model.py | 3 ++- .../gui/windows/live_viewer/test/model_test.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mantidimaging/gui/windows/live_viewer/model.py b/mantidimaging/gui/windows/live_viewer/model.py index 4db9b6386e5..ada244bad73 100644 --- a/mantidimaging/gui/windows/live_viewer/model.py +++ b/mantidimaging/gui/windows/live_viewer/model.py @@ -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): diff --git a/mantidimaging/gui/windows/live_viewer/test/model_test.py b/mantidimaging/gui/windows/live_viewer/test/model_test.py index 2751dc800be..88847753bac 100644 --- a/mantidimaging/gui/windows/live_viewer/test/model_test.py +++ b/mantidimaging/gui/windows/live_viewer/test/model_test.py @@ -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"): @@ -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"): @@ -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