Skip to content

Commit 0dc3c63

Browse files
author
Dimitar Tasev
committed
Removes outdates temp_shared_array, and pointless generate_indices
1 parent 8726f78 commit 0dc3c63

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

mantidimaging/core/parallel/utility.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ctypes
55
import multiprocessing
66
import os
7-
from contextlib import contextmanager
87
from functools import partial
98
from logging import getLogger
109
# COMPAT python 3.7 : Using heap instead of Array,
@@ -88,28 +87,10 @@ def _create_shared_array(shape, dtype: Union[str, np.dtype] = np.float32):
8887
return data.reshape(shape)
8988

9089

91-
@contextmanager
92-
def temp_shared_array(shape, dtype: NP_DTYPE = np.float32) -> np.ndarray:
93-
array = _create_shared_array(shape, dtype)
94-
try:
95-
yield array
96-
finally:
97-
pass
98-
99-
10090
def get_cores():
10191
return multiprocessing.cpu_count()
10292

10393

104-
def generate_indices(num_images):
105-
"""
106-
Generate indices for each image.
107-
108-
:param num_images: The number of images.
109-
"""
110-
return range(num_images)
111-
112-
11394
def calculate_chunksize(cores):
11495
# TODO possible proper calculation of chunksize, although best performance
11596
# has been with 1
@@ -143,7 +124,7 @@ def multiprocessing_necessary(shape: Union[int, Tuple[int, int, int]], cores) ->
143124
def execute_impl(img_num: int, partial_func: partial, cores: int, chunksize: int, progress: Progress, msg: str):
144125
task_name = f"{msg} {cores}c {chunksize}chs"
145126
progress = Progress.ensure_instance(progress, num_steps=img_num, task_name=task_name)
146-
indices_list = generate_indices(img_num)
127+
indices_list = range(img_num)
147128
if multiprocessing_necessary(img_num, cores):
148129
with Pool(cores) as pool:
149130
for _ in pool.imap(partial_func, indices_list, chunksize=chunksize):

0 commit comments

Comments
 (0)