Commit 44cbe21c authored by Thomas Vincent's avatar Thomas Vincent

use default n_proc in qspace conversion

parent c7d269bf
......@@ -41,6 +41,7 @@ import multiprocessing.sharedctypes as mp_sharedctypes
import numpy as np
import xrayutilities as xu
from ... import config
from ...util import bin_centers_to_range_step
from ...util.medianfilter import medfilt2d
from ...util.histogramnd_lut import histogramnd_get_lut, histogramnd_from_lut
......@@ -162,7 +163,10 @@ class QSpaceConverter(object):
""" Indices of sample positions that will be converted. """
n_proc = property(lambda self: self.__n_proc)
""" Number of processes to use. Will use cpu_count() if None or 0. """
"""Number of processes to use.
Uses the default config value if set to None.
roi = property(lambda self: self.__params['roi'])
""" Selected ROI in sample coordinates : [xmin, xmax, ymin, ymax] """
......@@ -243,7 +247,7 @@ class QSpaceConverter(object):
"""Whether or not to apply Maxipix module edges correction (bool)"""
self.__callback = callback
self.__n_proc = None
self.__n_proc = config.DEFAULT_PROCESS_NUMBER
self.__overwrite = False
self.__shared_progress = None
......@@ -925,12 +929,8 @@ class QSpaceConverter(object):
write_lock = manager.Lock()
idx_queue = manager.Queue()
n_proc = self.n_proc
if n_proc is None or n_proc <= 0:
n_proc = mp.cpu_count()
self.__shared_progress = mp_sharedctypes.RawArray(ctypes.c_int32,
np.frombuffer(self.__shared_progress, dtype='int32')[:] = 0
if shiftH5 is not None and shifted_idx is not None:
......@@ -948,7 +948,7 @@ class QSpaceConverter(object):
shared_shifted = None
shared_shifted_shape = None
pool = mp.Pool(n_proc,
pool = mp.Pool(self.n_proc,
......@@ -996,7 +996,7 @@ class QSpaceConverter(object):
# creating the processes
results = []
for th_idx in range(n_proc):
for th_idx in range(self.n_proc):
arg_list = (th_idx,
......@@ -1016,7 +1016,7 @@ class QSpaceConverter(object):
# sending the None value to let the threads know that they
# should return
for th_idx in range(n_proc):
for th_idx in range(self.n_proc):
......@@ -1098,19 +1098,13 @@ class QSpaceConverter(object):
def n_proc(self, n_proc):
""" Sets the number of processes to use. If None or 0 the number of
processes used will be the number returned by
if n_proc is None:
self.__n_proc = None
n_proc = int(n_proc)
if n_proc <= 0:
self.__n_proc = None
self.__n_proc = n_proc
raise ValueError('n_proc must be strictly positive')
self.__n_proc = n_proc
def abort(self, wait=True):
......@@ -60,9 +60,10 @@ def kmap_2_qspace(xsocsH5_f,
:type roi: *optional* `array_like` (x_min, x_max, y_min, y_max)
:param n_proc: number of process to use. If None, the number of process
used will be the one returned by multiprocessing.cpu_count().
:type n_proc: `int`
:param Union[int,None] n_proc:
number of process to use.
If None, the number of processes used will be the
default config value (usually the number of cores).
:param overwrite: if set to False, an exception will be raise if the output
file already exists.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment