Skip to content

Commit cd38d5d

Browse files
author
Dimitar Tasev
committed
Remove regression from merge
1 parent 25d3ec8 commit cd38d5d

File tree

7 files changed

+8
-96
lines changed

7 files changed

+8
-96
lines changed

mantidimaging/core/parallel/test/utility_test.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
# SPDX - License - Identifier: GPL-3.0-or-later
33

44
from unittest import mock
5-
import numpy as np
6-
import SharedArray as sa
75

8-
from mantidimaging.core.parallel.utility import (create_array, create_shared_name, execute_impl,
9-
free_all_owned_by_this_instance, multiprocessing_necessary)
6+
from mantidimaging.core.parallel.utility import execute_impl, multiprocessing_necessary
107

118

129
def test_correctly_chooses_parallel():
@@ -41,25 +38,6 @@ def test_execute_impl_par(mock_pool):
4138
assert mock_progress.update.call_count == 15
4239

4340

44-
def test_free_all_owned_by_this_instance():
45-
name1 = create_shared_name()
46-
name2 = create_shared_name()
47-
name3 = create_shared_name()
48-
create_array((10, 10), np.float32, name=name1)
49-
create_array((10, 10), np.float32, name=name2)
50-
create_array((10, 10), np.float32, name=name3)
51-
52-
temp_name = "not_this_instance"
53-
sa.create("not_this_instance", (10, 10))
54-
55-
free_all_owned_by_this_instance()
56-
assert name1 not in [arr.name.decode("utf-8") for arr in sa.list()]
57-
assert name2 not in [arr.name.decode("utf-8") for arr in sa.list()]
58-
assert name3 not in [arr.name.decode("utf-8") for arr in sa.list()]
59-
assert temp_name in [arr.name.decode("utf-8") for arr in sa.list()]
60-
sa.delete(temp_name)
61-
62-
6341
if __name__ == "__main__":
6442
import pytest
6543

mantidimaging/core/parallel/utility.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,6 @@
2525

2626
NP_DTYPE = Type[np.single]
2727

28-
INSTANCE_PREFIX = str(uuid.uuid4())
29-
30-
31-
def free_all_owned_by_this_instance():
32-
for arr in [array for array in sa.list() if array.name.decode("utf-8").startswith(INSTANCE_PREFIX)]:
33-
sa.delete(arr.name.decode("utf-8"))
34-
35-
36-
def has_other_shared_arrays() -> bool:
37-
return len(sa.list()) > 0
38-
39-
40-
def free_all():
41-
for arr in [array for array in sa.list()]:
42-
sa.delete(arr.name.decode("utf-8"))
43-
4428

4529
def enough_memory(shape, dtype):
4630
return full_size_KB(shape=shape, axis=0, dtype=dtype) < system_free_memory().kb()

mantidimaging/gui/windows/main/test/view_test.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
class MainWindowViewTest(unittest.TestCase):
2424
def setUp(self) -> None:
2525
with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
26-
with mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays", return_value=False):
27-
self.view = MainWindowView()
26+
self.view = MainWindowView()
2827
self.presenter = mock.MagicMock()
2928
self.view.presenter = self.presenter
3029

@@ -307,34 +306,3 @@ def test_get_images_from_stack_uuid(self):
307306

308307
self.presenter.get_stack_visualiser.assert_called_once_with(uuid)
309308
self.assertEqual(images, return_value)
310-
311-
@mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays")
312-
@mock.patch("mantidimaging.gui.windows.main.view.free_all")
313-
@mock.patch("mantidimaging.gui.windows.main.view.QMessageBox")
314-
def test_ask_user_to_free_data(self, QMessageBox: Mock, free_all: Mock, has_other_shared_arrays: Mock):
315-
has_other_shared_arrays.return_value = True
316-
# makes the clickedButton the same return value mock as the addButton return
317-
QMessageBox.return_value.clickedButton.return_value = QMessageBox.return_value.addButton.return_value
318-
319-
self.view.ask_user_to_free_data()
320-
321-
QMessageBox.return_value.setWindowTitle.assert_called_once()
322-
QMessageBox.return_value.setText.assert_called_once()
323-
self.assertEquals(QMessageBox.return_value.addButton.call_count, 2)
324-
QMessageBox.return_value.exec.assert_called_once()
325-
free_all.assert_called_once()
326-
327-
@mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays")
328-
@mock.patch("mantidimaging.gui.windows.main.view.free_all")
329-
@mock.patch("mantidimaging.gui.windows.main.view.QMessageBox")
330-
def test_ask_user_to_free_data_ignore_pressed(self, QMessageBox: Mock, free_all: Mock,
331-
has_other_shared_arrays: Mock):
332-
has_other_shared_arrays.return_value = True
333-
334-
self.view.ask_user_to_free_data()
335-
336-
QMessageBox.return_value.setWindowTitle.assert_called_once()
337-
QMessageBox.return_value.setText.assert_called_once()
338-
self.assertEquals(QMessageBox.return_value.addButton.call_count, 2)
339-
QMessageBox.return_value.exec.assert_called_once()
340-
free_all.assert_not_called()

mantidimaging/gui/windows/main/view.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os
55
from logging import getLogger
6+
from mantidimaging.core.utility.projection_angle_parser import ProjectionAngleFileParser
67
from typing import Optional
78
from uuid import UUID
89

@@ -88,23 +89,6 @@ def __init__(self):
8889
if WelcomeScreenPresenter.show_today():
8990
self.show_about()
9091

91-
if has_other_shared_arrays():
92-
self.ask_user_to_free_data()
93-
94-
def ask_user_to_free_data(self):
95-
msg_box = QMessageBox(self)
96-
msg_box.setWindowTitle("Previously loaded data found")
97-
msg_box.setText("This can happen if Mantid Imaging crashes, or there are multiple instances running.\n\n"
98-
"If Mantid Imaging crashed it is recommended to just 'Release all previous data'.\n\n"
99-
"If you have another instance running it is recommended you 'Ignore' "
100-
"otherwise the other instance will be corrupted.")
101-
delete_all = msg_box.addButton("Release all previous data", QMessageBox.ActionRole)
102-
_ = msg_box.addButton(QMessageBox.Ignore)
103-
msg_box.exec()
104-
105-
if msg_box.clickedButton() == delete_all:
106-
free_all()
107-
10892
def setup_shortcuts(self):
10993
self.actionLoad.triggered.connect(self.show_load_dialogue)
11094
self.actionSampleLoadLog.triggered.connect(self.load_sample_log_dialog)

mantidimaging/gui/windows/operations/test/test_view.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class OperationsWindowsViewTest(unittest.TestCase):
1717
def setUp(self):
1818
# mock the view so it has the same methods
1919
with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
20-
with mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays", return_value=False):
21-
self.main_window = MainWindowView()
20+
self.main_window = MainWindowView()
2221
self.window = FiltersWindowView(self.main_window)
2322

2423
def test_collapse(self):

mantidimaging/gui/windows/recon/test/view_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
class ReconstructWindowViewTest(unittest.TestCase):
2020
def setUp(self) -> None:
2121
with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
22-
with mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays", return_value=False):
23-
self.main_window = MainWindowView()
22+
self.main_window = MainWindowView()
2423
self.view = ReconstructWindowView(self.main_window)
2524
self.view.presenter = self.presenter = mock.Mock()
2625
self.view.image_view = self.image_view = mock.Mock()

mantidimaging/gui/windows/stack_visualiser/test/view_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import unittest
66

77
from unittest import mock
8+
from unittest.mock import Mock
9+
810
from PyQt5.QtWidgets import QDockWidget
9-
from mock import Mock
1011

1112
import mantidimaging.test_helpers.unit_test_helper as th
1213
from mantidimaging.core.data import Images
@@ -34,8 +35,7 @@ def tearDown(self) -> None:
3435

3536
def setUp(self):
3637
with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
37-
with mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays", return_value=False):
38-
self.window = MainWindowView()
38+
self.window = MainWindowView()
3939
self.window.remove_stack = mock.Mock()
4040
self.dock, self.view, self.test_data = self._add_stack_visualiser()
4141

0 commit comments

Comments
 (0)