From 8ebb19ac467a25473973c6a759f6b3006d7ce29e Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 5 Feb 2025 15:32:37 -0500 Subject: [PATCH 1/4] FIX: now works with Numba 0.61.0 --- pyxrf/core/map_processing.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pyxrf/core/map_processing.py b/pyxrf/core/map_processing.py index 5401b599..0b42031e 100644 --- a/pyxrf/core/map_processing.py +++ b/pyxrf/core/map_processing.py @@ -1143,6 +1143,7 @@ def compute_selected_rois( # is interest. The output of this function is tested to match the # output of 'snip_method' to make sure the functions are equivalent. + _default_con_val_no_bin = 3 _default_con_val_bin = 5 _default_iter_num_no_bin = 3 @@ -1225,6 +1226,7 @@ def snip_method_numba( geoscience applications", Nuclear Instruments and Methods in Physics Research Section B, vol. 34, 1998. """ + # clean input a bit if con_val is None: if spectral_binning is None: @@ -1319,7 +1321,12 @@ def _clip(arr, vmin, vmax): temp = (background[lo_index.astype(np.int32)] + background[hi_index.astype(np.int32)]) / 2.0 bg_index = background > temp - background[bg_index] = temp[bg_index] + # The following numpy based line of code stopped working with numba v0.61.0 + # background[bg_index] = temp[bg_index] + # The following code is the workaround. Seems fast enough. + for n in range(len(background)): + if bg_index[n]: + background[n] = temp[n] current_width = window_p max_current_width = np.amax(current_width) @@ -1331,7 +1338,12 @@ def _clip(arr, vmin, vmax): temp = (background[lo_index.astype(np.int32)] + background[hi_index.astype(np.int32)]) / 2.0 bg_index = background > temp - background[bg_index] = temp[bg_index] + # The following numpy based line of code stopped working with numba v0.61.0 + # background[bg_index] = temp[bg_index] + # The following code is the workaround. Seems fast enough. + for n in range(len(background)): + if bg_index[n]: + background[n] = temp[n] # decrease the width and repeat current_width = current_width / decrease_factor From a7e6b5f6ff5eed748b767c418414017fd9f59712 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 5 Feb 2025 16:48:53 -0500 Subject: [PATCH 2/4] FIX: compatibility with Matplotlib 3.10 --- pyxrf/model/lineplot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyxrf/model/lineplot.py b/pyxrf/model/lineplot.py index 96319839..1b62f986 100644 --- a/pyxrf/model/lineplot.py +++ b/pyxrf/model/lineplot.py @@ -1501,7 +1501,9 @@ def _show_preview_spectrum_plot(self): # Remove all lines from the plot while len(self._lines_preview): - self._lines_preview.pop().remove() + _ = self._lines_preview.pop() + if _.axes is not None: + _.remove() # The list of color names color_names = get_color_name() From a4c0e88676ed1da43d1003616ccce60cec4d775e Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 5 Feb 2025 16:51:56 -0500 Subject: [PATCH 3/4] DOC: added comment --- pyxrf/model/lineplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyxrf/model/lineplot.py b/pyxrf/model/lineplot.py index 1b62f986..e8eb5934 100644 --- a/pyxrf/model/lineplot.py +++ b/pyxrf/model/lineplot.py @@ -1499,7 +1499,7 @@ def _show_preview_spectrum_plot(self): # Completely redraw the plot each time the function is called self.prepare_preview_spectrum_plot() - # Remove all lines from the plot + # Remove all lines from the plot. This is not really needed, since the axes are cleared. while len(self._lines_preview): _ = self._lines_preview.pop() if _.axes is not None: From 66be934895494fe004a95287248cf253e1fd0f4a Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 5 Feb 2025 19:35:32 -0500 Subject: [PATCH 4/4] FIX: remove unnecessary code for removing artists --- pyxrf/model/lineplot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyxrf/model/lineplot.py b/pyxrf/model/lineplot.py index e8eb5934..501b70b7 100644 --- a/pyxrf/model/lineplot.py +++ b/pyxrf/model/lineplot.py @@ -1500,10 +1500,10 @@ def _show_preview_spectrum_plot(self): self.prepare_preview_spectrum_plot() # Remove all lines from the plot. This is not really needed, since the axes are cleared. - while len(self._lines_preview): - _ = self._lines_preview.pop() - if _.axes is not None: - _.remove() + # while len(self._lines_preview): + # _ = self._lines_preview.pop() + # if _.axes is not None: + # _.remove() # The list of color names color_names = get_color_name()