Skip to content

Commit

Permalink
remove MainWindowPresenter.add_180_deg_file_to_dataset and associated…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
MikeSullivan7 committed Nov 20, 2024
1 parent 31d961d commit 68f80e6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
17 changes: 0 additions & 17 deletions mantidimaging/gui/windows/main/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,6 @@ def get_existing_180_id(self, dataset_id: uuid.UUID) -> uuid.UUID | None:
return dataset.proj180deg.id
return None

def add_180_deg_to_dataset(self, dataset_id: uuid.UUID, _180_deg_file: str) -> ImageStack:
"""
Loads the 180 projection and adds this to a given Dataset ID.
:param dataset_id: The ID of the Dataset.
:param _180_deg_file: The location of the 180 projection.
:return: The loaded 180 ImageStack object.
"""
dataset = self.datasets.get(dataset_id)
if not dataset:
raise RuntimeError(f"Failed to get Dataset with ID {dataset_id}")
if not dataset.sample:
raise RuntimeError(f"Dataset with ID {dataset_id} does not have a sample")

_180_deg = loader.load_stack_from_group(FilenameGroup.from_file(_180_deg_file))
dataset.proj180deg = _180_deg
return _180_deg

def add_projection_angles_to_sample(self, images_id: uuid.UUID, proj_angles: ProjectionAngles) -> None:
images = self.get_images_by_uuid(images_id)
if images is None:
Expand Down
24 changes: 0 additions & 24 deletions mantidimaging/gui/windows/main/test/presenter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,30 +265,6 @@ def test_get_stack_with_images_failure(self):
with self.assertRaises(RuntimeError):
self.presenter.get_stack_with_images(generate_images())

def test_add_first_180_deg_to_dataset(self):
self.model.datasets[self.dataset.id] = self.dataset
filename_for_180 = "path/to/180"
self.model.get_existing_180_id.return_value = None
self.model.add_180_deg_to_dataset.return_value = _180_deg = generate_images((1, 200, 200))
self.presenter.add_images_to_existing_dataset = mock.Mock()

self.presenter.add_180_deg_file_to_dataset(self.dataset.id, filename_for_180)
self.model.add_180_deg_to_dataset.assert_called_once_with(self.dataset.id, filename_for_180)
self.presenter.add_images_to_existing_dataset.assert_called_once_with(self.dataset.id, _180_deg, "proj_180")

def test_replace_180_deg_in_dataset(self):
self.model.datasets[self.dataset.id] = self.dataset
dataset_id = self.dataset.id
filename_for_180 = "path/to/180"
self.model.get_existing_180_id.return_value = existing_180_id = "prev-id"
self.presenter.stack_visualisers[existing_180_id] = existing_180_stack = mock.Mock()
self.model.add_180_deg_to_dataset.return_value = _180_deg = generate_images((1, 200, 200))

self.presenter.add_180_deg_file_to_dataset(dataset_id, filename_for_180)
self.model.add_180_deg_to_dataset.assert_called_once_with(dataset_id, filename_for_180)
self.assertNotIn(existing_180_stack, self.presenter.stack_visualisers)
self.view.model_changed.emit.assert_called_once()

def test_add_projection_angles_to_stack(self):
id, angles = "doesn't-exist", ProjectionAngles(np.ndarray([1]))
self.presenter.add_projection_angles_to_sample(id, angles)
Expand Down

0 comments on commit 68f80e6

Please sign in to comment.