From 0668db5bf6ddcd24770db7d880dbea0d9672f059 Mon Sep 17 00:00:00 2001 From: leloup314 Date: Fri, 1 Sep 2023 18:03:08 +0200 Subject: [PATCH 1/6] FIX: drop deprccated use of numpy dtypes e.g. np.bool --- irrad_spectroscopy/spectroscopy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irrad_spectroscopy/spectroscopy.py b/irrad_spectroscopy/spectroscopy.py index 96108b3..9baf880 100644 --- a/irrad_spectroscopy/spectroscopy.py +++ b/irrad_spectroscopy/spectroscopy.py @@ -248,7 +248,7 @@ def interpolate_bkg(counts, channels=None, window=5, order=3, scale=0.5, energy_ dy_mv_avg = [np.mean(dy_mv_avg[i:i + (window * (order - o))]) for i in range(dy.shape[0])] # make mask - bkg_mask = np.append(np.abs(dy_mv_avg) <= scale * np.mean(np.abs(dy_mv_avg)), np.array([0], dtype=np.bool)) + bkg_mask = np.append(np.abs(dy_mv_avg) <= scale * np.mean(np.abs(dy_mv_avg)), np.array([0], dtype=bool)) # interpolate the masked array into array, then create function and append to estimates bkg_estimates.append(interp1d(_chnnls, np.interp(_chnnls, _chnnls[bkg_mask], _cnts[bkg_mask]), kind='quadratic')) @@ -371,7 +371,7 @@ def fit_spectrum(counts, channels=None, bkg=None, local_bkg=True, n_peaks=None, # boolean masks # masking regions due to failing general conditions (peak_mask) # masking successfully fitted regions (peak_mask_fitted) - peak_mask, peak_mask_fitted = np.ones_like(_cnts, dtype=np.bool), np.ones_like(_cnts, dtype=np.bool) + peak_mask, peak_mask_fitted = np.ones_like(_cnts, dtype=bool), np.ones_like(_cnts, dtype=bool) # flag whether expected peaks have been checked checked_expected = False From 98770f21d9da9b1bf98bcdee0e0339c254f25a95 Mon Sep 17 00:00:00 2001 From: leloup314 Date: Fri, 1 Sep 2023 18:08:43 +0200 Subject: [PATCH 2/6] FIX: deprecated use of collections.Iterable instead of collections.abc.Iterable --- irrad_spectroscopy/spectroscopy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/irrad_spectroscopy/spectroscopy.py b/irrad_spectroscopy/spectroscopy.py index 9baf880..7d58c35 100644 --- a/irrad_spectroscopy/spectroscopy.py +++ b/irrad_spectroscopy/spectroscopy.py @@ -12,7 +12,8 @@ import irrad_spectroscopy as isp from irrad_spectroscopy.spec_utils import get_isotope_info, source_to_dict from irrad_spectroscopy.physics import decay_law, gamma_dose_rate -from collections import OrderedDict, Iterable +from collections import OrderedDict +from collections.abc import Iterable from scipy.optimize import curve_fit, fsolve, OptimizeWarning from scipy.integrate import quad from scipy.interpolate import interp1d From b28d108e1150a49664d7ffe806254704da9bf24f Mon Sep 17 00:00:00 2001 From: Klaas Padeken Date: Mon, 26 Feb 2024 13:55:16 +0100 Subject: [PATCH 3/6] added compatibility for python 3.11+ --- irrad_spectroscopy/spectroscopy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/irrad_spectroscopy/spectroscopy.py b/irrad_spectroscopy/spectroscopy.py index 7d58c35..aad217a 100644 --- a/irrad_spectroscopy/spectroscopy.py +++ b/irrad_spectroscopy/spectroscopy.py @@ -18,6 +18,11 @@ from scipy.integrate import quad from scipy.interpolate import interp1d +try: + from inspect import getfullargspec as get_args +except ImportError: + from inspect import getargspec as get_args + # set logging level when doing import logging.getLogger().setLevel(logging.INFO) @@ -529,7 +534,7 @@ def tmp_fit(x, *args): finally: k += .5 _p0 = {'mu': _mu, 'sigma': _sigma, 'h': y_peak} - fit_args = inspect.getargspec(peak_fit)[0][1:] + fit_args = get_args(peak_fit)[0][1:] p0 = tuple(_p0[arg] if arg in _p0 else 1 for arg in fit_args) popt, pcov = curve_fit(tmp_fit, x_fit, y_fit, p0=p0, sigma=np.sqrt(y_fit), absolute_sigma=True, maxfev=5000) perr = np.sqrt(np.diag(pcov)) # get std deviation From dafea3138ced00f6a17819aaae1bf6b20b45af97 Mon Sep 17 00:00:00 2001 From: leloup314 Date: Wed, 6 Mar 2024 22:44:33 +0100 Subject: [PATCH 4/6] MAINT: remove unused import --- irrad_spectroscopy/spectroscopy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irrad_spectroscopy/spectroscopy.py b/irrad_spectroscopy/spectroscopy.py index aad217a..c6b38fc 100644 --- a/irrad_spectroscopy/spectroscopy.py +++ b/irrad_spectroscopy/spectroscopy.py @@ -6,7 +6,6 @@ # Imports import logging -import inspect import warnings import numpy as np import irrad_spectroscopy as isp @@ -18,6 +17,7 @@ from scipy.integrate import quad from scipy.interpolate import interp1d +# Fix for Python >= 3.11 try: from inspect import getfullargspec as get_args except ImportError: From ec07a84d468dd1ce7f85c36ab5470c1307617088 Mon Sep 17 00:00:00 2001 From: leloup314 Date: Wed, 6 Mar 2024 22:46:15 +0100 Subject: [PATCH 5/6] MAINT: update testing for Py-versions --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 849a05e..2b09277 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,13 +18,13 @@ jobs: # This workflow contains a single job called "build" tests: name: Testing on Python ${{matrix.python-version}} | ${{matrix.sim}} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: os: [ubuntu-20.04, ubuntu-latest] - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.10, 3.11] # Steps represent a sequence of tasks that will be executed as part of the job steps: From 0441392de225f0059c68d1e591f75ebac100746d Mon Sep 17 00:00:00 2001 From: leloup314 Date: Wed, 6 Mar 2024 22:47:23 +0100 Subject: [PATCH 6/6] MAINT: update testing for Py-versions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b09277..7404090 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, ubuntu-latest] - python-version: [3.7, 3.10, 3.11] + python-version: ["3.7", "3.10", "3.11"] # Steps represent a sequence of tasks that will be executed as part of the job steps: