Skip to content

Commit

Permalink
Changes requested Part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSullivan7 committed Jan 22, 2025
1 parent 60ac802 commit 25001e0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
6 changes: 3 additions & 3 deletions mantidimaging/eyes_tests/live_viewer_window_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_live_view_opens_without_data(self, _mock_time, _mock_image_watcher):
self.imaging.show_live_viewer(self.live_directory)
self.check_target(widget=self.imaging.live_viewer_list[-1])

@mock.patch('mantidimaging.gui.windows.live_viewer.model.load_image_from_path')
@mock.patch('mantidimaging.gui.windows.live_viewer.presenter.LiveViewerWindowPresenter.load_image_from_path')
@mock.patch('mantidimaging.gui.windows.live_viewer.model.ImageWatcher')
@mock.patch("time.time", return_value=4000.0)
def test_live_view_opens_with_data(self, _mock_time, _mock_image_watcher, mock_load_image):
Expand All @@ -67,7 +67,7 @@ def test_live_view_opens_with_data(self, _mock_time, _mock_image_watcher, mock_l
self.imaging.live_viewer_list[-1].presenter.model._handle_image_changed_in_list(image_list)
self.check_target(widget=self.imaging.live_viewer_list[-1])

@mock.patch('mantidimaging.gui.windows.live_viewer.model.load_image_from_path')
@mock.patch('mantidimaging.gui.windows.live_viewer.presenter.LiveViewerWindowPresenter.load_image_from_path')
@mock.patch('mantidimaging.gui.windows.live_viewer.model.ImageWatcher')
@mock.patch("time.time", return_value=4000.0)
def test_live_view_opens_with_bad_data(self, _mock_time, _mock_image_watcher, mock_load_image):
Expand All @@ -78,7 +78,7 @@ def test_live_view_opens_with_bad_data(self, _mock_time, _mock_image_watcher, mo
self.imaging.live_viewer_list[-1].presenter.model._handle_image_changed_in_list(image_list)
self.check_target(widget=self.imaging.live_viewer_list[-1])

@mock.patch('mantidimaging.gui.windows.live_viewer.model.load_image_from_path')
@mock.patch('mantidimaging.gui.windows.live_viewer.presenter.LiveViewerWindowPresenter.load_image_from_path')
@mock.patch('mantidimaging.gui.windows.live_viewer.model.ImageWatcher')
@mock.patch("time.time", return_value=4000.0)
def test_rotate_operation_rotates_image(self, _mock_time, _mock_image_watcher, mock_load_image):
Expand Down
7 changes: 2 additions & 5 deletions mantidimaging/gui/windows/live_viewer/live_view_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LiveViewWidget(GraphicsLayoutWidget):
@param parent: The parent widget
"""
image: MIMiniImageView
image_shape: tuple = (-1, -1)
image_shape: tuple[int, int] | None = None
roi_changed = pyqtSignal()
roi_changing = pyqtSignal()
roi_object: SpectrumROI | None = None
Expand Down Expand Up @@ -58,7 +58,7 @@ def show_error(self, message: str | None) -> None:
self.image.show_message(message)

def add_roi(self) -> None:
if self.image_shape == (-1, -1):
if self.image_shape is None:
return
height, width = self.image_shape
roi = SensibleROI.from_list([0, 0, width, height])
Expand All @@ -69,9 +69,6 @@ def add_roi(self) -> None:
self.roi_object.roi.sigRegionChanged.connect(self.roi_changing.emit)
self.image.vb.addItem(self.roi_object.roi)

def set_image_shape(self, shape: tuple) -> None:
self.image_shape = shape

def get_roi(self) -> SensibleROI | None:
if not self.roi_object:
return None
Expand Down
10 changes: 0 additions & 10 deletions mantidimaging/gui/windows/live_viewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,10 @@ def _get_oldest_image(self) -> Image_Data:
def _remove_oldest_image(self) -> None:
del self.cache_dict[self._get_oldest_image()]

<<<<<<< HEAD
<<<<<<< HEAD
=======
def use_loading_function(self, func: typing.Callable) -> None:
self.loading_func = func

>>>>>>> 3adccbe19 (pass loading function from presenter to ImageCache)
def load_image(self, image: Image_Data) -> np.ndarray | None:
=======
def use_loading_function(self, func: typing.Callable) -> None:
self.loading_func = func

def load_image(self, image: Image_Data) -> np.ndarray:
>>>>>>> b65e2adfa (fixup! mypy type annotations)
if image in self.cache_dict.keys():
return self.cache_dict[image]
else:
Expand Down
6 changes: 3 additions & 3 deletions mantidimaging/gui/windows/live_viewer/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from collections.abc import Callable
from logging import getLogger
import numpy as np
import tifffile
from PyQt5.QtCore import pyqtSignal, QObject, QThread, QTimer
from astropy.io import fits

from imagecodecs._deflate import DeflateError
from tifffile import tifffile

from mantidimaging.gui.mvp_base import BasePresenter
from mantidimaging.gui.windows.live_viewer.model import LiveViewerWindowModel, Image_Data, ImageCache
from mantidimaging.gui.windows.live_viewer.model import LiveViewerWindowModel, Image_Data
from mantidimaging.core.operations.loader import load_filter_packages
from mantidimaging.core.data import ImageStack

Expand Down Expand Up @@ -242,4 +242,4 @@ def set_roi_enabled(self, enable: bool) -> None:
def try_next_mean_chunk(self) -> None:
if np.isnan(self.model.mean).any():
if not self.handle_roi_change_timer.isActive():
self.handle_roi_change_timer.start(100)
self.handle_roi_change_timer.start(10)
1 change: 0 additions & 1 deletion mantidimaging/gui/windows/live_viewer/test/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def setUp(self) -> None:
self.image_array_mock_list = [np.random.default_rng().random(5)] * 5
for i in range(5):
self.image_data_list.append(mock.create_autospec(Image_Data))
self.image_data_list[i] = mock.create_autospec(Image_Data)
self.image_data_list[i].image_path = Path(f"abc_{i}.tif")
self.image_data_list[i].image_modified_time = random.uniform(1000, 10000)
self.image_cache = ImageCache()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_WHEN_nans_in_mean_THEN_handle_roi_change_timer_start(self):
self.presenter.handle_roi_change_timer = mock.Mock()
self.presenter.handle_roi_change_timer.isActive.return_value = False
self.presenter.try_next_mean_chunk()
self.presenter.handle_roi_change_timer.start.assert_called_once_with(100)
self.presenter.handle_roi_change_timer.start.assert_called_once_with(10)

def test_WHEN_no_nans_in_mean_THEN_handle_roi_change_timer_not_started(self):
self.model.mean = np.array([1, 2, 3, 4])
Expand Down

0 comments on commit 25001e0

Please sign in to comment.