From e1154c2a9469a0461bd0edb7b334f0ebb7c0a091 Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Mon, 4 Mar 2024 05:07:03 +0000 Subject: [PATCH] testing compute operations --- mantidimaging/core/operations/divide/divide.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mantidimaging/core/operations/divide/divide.py b/mantidimaging/core/operations/divide/divide.py index bc65689da93..04db2bacc3e 100644 --- a/mantidimaging/core/operations/divide/divide.py +++ b/mantidimaging/core/operations/divide/divide.py @@ -6,6 +6,9 @@ from typing import Union, Callable, Dict, Any, TYPE_CHECKING from mantidimaging import helper as h +import numpy as np + +from mantidimaging.core.parallel import shared as ps from mantidimaging.core.operations.base_filter import BaseFilter from mantidimaging.gui.utility.qt_helpers import Type @@ -43,9 +46,16 @@ def filter_func(images: ImageStack, value: Union[int, float] = 0, unit="micron", if unit == "micron": value *= 1e-4 - images.data /= value + params = {'value': value} + ps.run_compute_func(DivideFilter.compute_function, images.data.shape[0], images.shared_array, params, progress) + return images + @staticmethod + def compute_function(i: int, array: np.ndarray, params: dict): + value = params['value'] + array[i] /= value + @staticmethod def register_gui(form: 'QFormLayout', on_change: Callable, view: 'BasePresenter') -> Dict[str, Any]: from mantidimaging.gui.utility import add_property_to_form @@ -75,9 +85,3 @@ def execute_wrapper( # type: ignore value = value_widget.value() unit = unit_widget.currentText() return partial(DivideFilter.filter_func, value=value, unit=unit) - - @staticmethod - def validate_execute_kwargs(kwargs: Dict[str, Any]) -> bool: - if 'value_widget' not in kwargs: - return False - return True