Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify datasets 9: Remove MixedDataset #2401

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions mantidimaging/core/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ def is_processed(self) -> bool:
return False


class MixedDataset(Dataset):
pass


class StrictDataset(Dataset):
pass

Expand Down
61 changes: 0 additions & 61 deletions mantidimaging/core/data/test/mixeddataset_test.py

This file was deleted.

4 changes: 2 additions & 2 deletions mantidimaging/eyes_tests/reconstruct_window_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from mantidimaging.eyes_tests.base_eyes import BaseEyesTest
from mantidimaging.test_helpers.unit_test_helper import generate_images
from mantidimaging.core.data.dataset import MixedDataset
from mantidimaging.core.data.dataset import Dataset
from mantidimaging.test_helpers.qt_test_helpers import wait_until


Expand Down Expand Up @@ -56,7 +56,7 @@ def test_reconstruction_window_reconstruct_tab(self):
def test_negative_nan_overlay(self):
images = generate_images(seed=10)
images.name = "bad_data"
ds = MixedDataset(stacks=[images])
ds = Dataset(stacks=[images])
self.imaging.presenter.model.add_dataset_to_model(ds)
self.imaging.presenter.create_single_tabbed_images_stack(images)
QApplication.sendPostedEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import unittest
from unittest import mock

from mantidimaging.core.data.dataset import StrictDataset, MixedDataset
from mantidimaging.core.data.dataset import StrictDataset, Dataset
from mantidimaging.gui.widgets.dataset_selector.presenter import DatasetSelectorWidgetPresenter, Notification
from mantidimaging.gui.widgets.dataset_selector.view import DatasetSelectorWidgetView

Expand Down Expand Up @@ -33,7 +33,7 @@ def setUp(self) -> None:
self.ds1.name = "Dataset 1"
self.ds2 = StrictDataset(sample=self.img2, flat_before=self.img3)
self.ds2.name = "Dataset 2"
self.ds3 = MixedDataset(stacks=[self.img4])
self.ds3 = Dataset(stacks=[self.img4])
self.ds3.name = "Dataset 3"

def test_handle_selection_no_matching_index_found(self):
Expand Down
10 changes: 5 additions & 5 deletions mantidimaging/gui/windows/main/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import NoReturn, TYPE_CHECKING

from mantidimaging.core.data import ImageStack
from mantidimaging.core.data.dataset import StrictDataset, MixedDataset, Dataset
from mantidimaging.core.data.dataset import StrictDataset, Dataset
from mantidimaging.core.io import loader, saver
from mantidimaging.core.io.filenames import FilenameGroup
from mantidimaging.core.io.loader.loader import LoadingParameters, ImageParameters
Expand Down Expand Up @@ -60,11 +60,11 @@ def load(im_param: ImageParameters) -> ImageStack:
self.datasets[ds.id] = ds
return ds

def load_images_into_mixed_dataset(self, file_path: str, progress: Progress) -> MixedDataset:
def load_image_stack_to_new_dataset(self, file_path: str, progress: Progress) -> Dataset:
images = self.load_image_stack(file_path, progress)
sd = MixedDataset(stacks=[images], name=images.name)
self.datasets[sd.id] = sd
return sd
ds = Dataset(stacks=[images], name=images.name)
self.datasets[ds.id] = ds
return ds

def load_image_stack(self, file_path: str, progress: Progress) -> ImageStack:
group = FilenameGroup.from_file(Path(file_path))
Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/gui/windows/main/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def save_nexus_file(self) -> None:
busy=True)

def load_image_stack(self, file_path: str) -> None:
start_async_task_view(self.view, self.model.load_images_into_mixed_dataset, self._on_dataset_load_done,
start_async_task_view(self.view, self.model.load_image_stack_to_new_dataset, self._on_dataset_load_done,
{'file_path': file_path})

def _open_window_if_not_open(self) -> None:
Expand Down
14 changes: 7 additions & 7 deletions mantidimaging/gui/windows/main/test/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from mantidimaging.core.data import ImageStack
from mantidimaging.core.data.dataset import StrictDataset, MixedDataset, Dataset
from mantidimaging.core.data.dataset import StrictDataset, Dataset
from mantidimaging.core.io.loader.loader import LoadingParameters, ImageParameters
from mantidimaging.core.utility.data_containers import ProjectionAngles, FILE_TYPES, Indices
from mantidimaging.gui.windows.main import MainWindowModel
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_load_stack(self, fng_mock: mock.MagicMock, loader: mock.MagicMock):
group = mock.Mock()
fng_mock.from_file.return_value = group

self.model.load_images_into_mixed_dataset(file_path, progress)
self.model.load_image_stack_to_new_dataset(file_path, progress)

loader.load_stack_from_group.assert_called_once_with(group, progress)

Expand Down Expand Up @@ -393,7 +393,7 @@ def test_remove_images_from_mixed_dataset(self):
ids = [image_stack.id for image_stack in images]
id_to_remove = ids[0]

ds = MixedDataset(stacks=images)
ds = Dataset(stacks=images)
self.model.datasets[ds.id] = ds

deleted_stacks = self.model.remove_container(id_to_remove)
Expand All @@ -418,7 +418,7 @@ def test_proj180s(self):

ds1 = StrictDataset(sample=generate_images())
ds2 = StrictDataset(sample=generate_images())
ds3 = MixedDataset(stacks=[generate_images()])
ds3 = Dataset(stacks=[generate_images()])

proj180s = [ImageStack(ds1.sample.data[0]), ImageStack(ds2.sample.data[0])]
ds1.proj180deg = proj180s[0]
Expand Down Expand Up @@ -451,16 +451,16 @@ def test_delete_all_recons_in_dataset(self):
self.assertListEqual(ds.recons.stacks, [])

def test_get_all_recon_list_ids(self):
ds1 = MixedDataset()
ds2 = MixedDataset()
ds1 = Dataset()
ds2 = Dataset()

self.model.add_dataset_to_model(ds1)
self.model.add_dataset_to_model(ds2)

self.assertListEqual(self.model.recon_list_ids, [ds1.recons.id, ds2.recons.id])

def test_get_recon_list_id(self):
ds = MixedDataset()
ds = Dataset()
self.model.add_dataset_to_model(ds)

assert self.model.get_recon_list_id(ds.id) == ds.recons.id
Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/gui/windows/main/test/presenter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_load_stack(self, start_async_mock: mock.Mock):

self.presenter.load_image_stack(file_path)

start_async_mock.assert_called_once_with(self.view, self.presenter.model.load_images_into_mixed_dataset,
start_async_mock.assert_called_once_with(self.view, self.presenter.model.load_image_stack_to_new_dataset,
self.presenter._on_dataset_load_done, {'file_path': file_path})

def test_add_stack(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from PyQt5.QtWidgets import QPushButton, QActionGroup, QGroupBox, QAction, QCheckBox, QTabWidget
from parameterized import parameterized

from mantidimaging.core.data.dataset import StrictDataset, MixedDataset
from mantidimaging.core.data.dataset import StrictDataset, Dataset
from mantidimaging.core.utility.sensible_roi import SensibleROI
from mantidimaging.gui.windows.main import MainWindowView
from mantidimaging.gui.windows.spectrum_viewer import SpectrumViewerWindowView, SpectrumViewerWindowPresenter
Expand Down Expand Up @@ -103,9 +103,9 @@ def test_handle_sample_change_dataset_unchanged(self):
self.presenter.main_window.get_dataset.assert_not_called()
self.assertEqual(self.view.current_dataset_id, initial_dataset_id)

def test_handle_sample_change_to_MixedDataset(self):
def test_handle_sample_change_to_dataset_no_sample(self):
self.presenter.get_dataset_id_for_stack = mock.Mock(return_value=uuid.uuid4())
new_dataset = MixedDataset(stacks=[generate_images()])
new_dataset = Dataset(stacks=[generate_images()])
self.presenter.main_window.get_dataset = mock.Mock(return_value=new_dataset)
self.presenter.main_window.get_stack = mock.Mock(return_value=generate_images())
self.presenter.show_new_sample = mock.Mock()
Expand Down
10 changes: 5 additions & 5 deletions mantidimaging/gui/windows/stack_visualiser/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from mantidimaging.gui.mvp_base import BasePresenter
from .model import SVModel
from ...utility.common import operation_in_progress
from mantidimaging.core.data.dataset import MixedDataset
from mantidimaging.core.data.dataset import Dataset

if TYPE_CHECKING:
from .view import StackVisualiserView # pragma: no cover
Expand Down Expand Up @@ -114,17 +114,17 @@ def dupe_stack(self):
"The data is being copied, this may take a while.", self.view):
new_images = self.images.copy(flip_axes=False)
new_images.name = self.images.name
self.add_mixed_dataset_to_model_and_update_view(new_images)
self.add_new_dataset_to_model_and_update_view(new_images)

def dupe_stack_roi(self):
with operation_in_progress("Copying data, this may take a while",
"The data is being copied, this may take a while.", self.view):
new_images = self.images.copy_roi(SensibleROI.from_points(*self.view.image_view.get_roi()))
new_images.name = self.images.name
self.add_mixed_dataset_to_model_and_update_view(new_images)
self.add_new_dataset_to_model_and_update_view(new_images)

def add_mixed_dataset_to_model_and_update_view(self, images: ImageStack):
dataset = MixedDataset(stacks=[images], name=images.name)
def add_new_dataset_to_model_and_update_view(self, images: ImageStack):
dataset = Dataset(stacks=[images], name=images.name)
self.view._main_window.presenter.model.add_dataset_to_model(dataset)
self.view._main_window.presenter.update_dataset_tree()
self.view._main_window.presenter.create_dataset_stack_visualisers(dataset)
Expand Down
Loading