ENH: frame_center_radon: do not use multiprocessing with `nproc=1`
@@ -468,13 +468,25 @@ def frame_center_radon(array, cropsize=101, hsize=0.4, step=0.01,
if nproc is None:
nproc = cpu_count() // 2 # Hyper-threading doubles the # of cores
- pool = Pool(processes=nproc)
+
if satspots:
- res = pool.map(EFT, zip(itt.repeat(_radon_costf2), itt.repeat(frame),
- itt.repeat(cent), itt.repeat(radint), coords))
+ costfkt = _radon_costf2
else:
- res = pool.map(EFT, zip(itt.repeat(_radon_costf), itt.repeat(frame),
- itt.repeat(cent), itt.repeat(radint), coords))
+ costfkt = _radon_costf
+
+
+ if nproc == 1:
+ costf = []
+ for coord in coords:
+ res = costfkt(frame, cent, radint, coord)
+ costf.append(res)
+ costf = np.array(costf)
+ elif nproc > 1:
+ pool = Pool(processes=nproc)
+ res = pool.map(EFT, zip(itt.repeat(costfkt),
+ itt.repeat(frame), itt.repeat(cent),
+ itt.repeat(radint), coords))
+
costf = np.array(res)
pool.close()
