Skip to content

Commit 8ebb19a

Browse files
committed
FIX: now works with Numba 0.61.0
1 parent 938db81 commit 8ebb19a

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

pyxrf/core/map_processing.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ def compute_selected_rois(
11431143
# is interest. The output of this function is tested to match the
11441144
# output of 'snip_method' to make sure the functions are equivalent.
11451145

1146+
11461147
_default_con_val_no_bin = 3
11471148
_default_con_val_bin = 5
11481149
_default_iter_num_no_bin = 3
@@ -1225,6 +1226,7 @@ def snip_method_numba(
12251226
geoscience applications", Nuclear Instruments and Methods in
12261227
Physics Research Section B, vol. 34, 1998.
12271228
"""
1229+
12281230
# clean input a bit
12291231
if con_val is None:
12301232
if spectral_binning is None:
@@ -1319,7 +1321,12 @@ def _clip(arr, vmin, vmax):
13191321
temp = (background[lo_index.astype(np.int32)] + background[hi_index.astype(np.int32)]) / 2.0
13201322

13211323
bg_index = background > temp
1322-
background[bg_index] = temp[bg_index]
1324+
# The following numpy based line of code stopped working with numba v0.61.0
1325+
# background[bg_index] = temp[bg_index]
1326+
# The following code is the workaround. Seems fast enough.
1327+
for n in range(len(background)):
1328+
if bg_index[n]:
1329+
background[n] = temp[n]
13231330

13241331
current_width = window_p
13251332
max_current_width = np.amax(current_width)
@@ -1331,7 +1338,12 @@ def _clip(arr, vmin, vmax):
13311338
temp = (background[lo_index.astype(np.int32)] + background[hi_index.astype(np.int32)]) / 2.0
13321339

13331340
bg_index = background > temp
1334-
background[bg_index] = temp[bg_index]
1341+
# The following numpy based line of code stopped working with numba v0.61.0
1342+
# background[bg_index] = temp[bg_index]
1343+
# The following code is the workaround. Seems fast enough.
1344+
for n in range(len(background)):
1345+
if bg_index[n]:
1346+
background[n] = temp[n]
13351347

13361348
# decrease the width and repeat
13371349
current_width = current_width / decrease_factor

0 commit comments

Comments
 (0)