-
Notifications
You must be signed in to change notification settings - Fork 6
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
changing operations to compute function #2066
Conversation
@@ -31,8 +30,8 @@ class RebinFilter(BaseFilter): | |||
filter_name = "Rebin" | |||
link_histograms = True | |||
|
|||
@staticmethod | |||
def filter_func(images: ImageStack, rebin_param=0.5, mode=None, progress=None) -> ImageStack: | |||
@classmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change back to staticmethod
progress=progress) | ||
images.shared_array = empty_resized_data | ||
params = {'new_shape': new_shape, 'mode': mode} | ||
ps.run_compute_func(cls.compute_function, images.data.shape[0], images.shared_array, params, progress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ps.run_compute_func(RebinFilter.compute_function, images.data.shape[0], [images.shared_array, empty_resized_data], params, progress)
|
||
empty_resized_data = _create_reshaped_array(images, rebin_param) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to keep this
def compute_function(i: int, array: np.ndarray, params: dict): | ||
new_shape = params['new_shape'] | ||
mode = params['mode'] | ||
array[i] = resize(array[i], output_shape=new_shape, mode=mode, preserve_range=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def compute_function(i: int, arrays: list[np.ndarray], params: dict):
new_shape = params['new_shape']
mode = params['mode']
input_array, output_array = arrays
output_array[i] = resize(input_array[i], output_shape=new_shape, mode=mode, preserve_range=True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AttributeError: 'numpy.ndarray' object has no attribute 'has_shared_memory'
i have changed the code to fix this
Split into other PRs |
Summary of Changes
This pull request implements a significant shift in how operations are executed within our project, addressing issue. the code is moving from a partial function execution style to adopting a
compute_function
method across various operations. This transition facilitates a clearer separation between the setup and execution phases of operations.Key Changes:
compute_function
static method in multiple operation classes, standardising the execution approach. This method encapsulates the core logic for operation execution on a per-slice basis.compute_function
method, ensuring all operations are compatible with this standardised approach.compute_function