File: avoid-division-by-zero.patch

package info (click to toggle)
dipy 1.11.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 17,144 kB
  • sloc: python: 92,240; makefile: 272; pascal: 183; sh: 162; ansic: 106
file content (15 lines) | stat: -rw-r--r-- 670 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Description: Avoid division by zero on single-CPU systems
Author: Santiago Vila <sanvila@debian.org>
Last-Update: 2025-03-22

--- a/dipy/reconst/multi_voxel.py
+++ b/dipy/reconst/multi_voxel.py
@@ -100,7 +100,7 @@
             if weights_is_array:
                 weights_to_fit = weights[np.where(mask)]
             single_voxel_with_self = partial(single_voxel_fit, self)
-            n_jobs = kwargs.get("n_jobs", multiprocessing.cpu_count() - 1)
+            n_jobs = kwargs.get("n_jobs", max(multiprocessing.cpu_count() - 1, 1))
             vox_per_chunk = kwargs.get(
                 "vox_per_chunk", np.max([data_to_fit.shape[0] // n_jobs, 1])
             )