Skip to content

Commit 1f2af06

Browse files
author
Pascal Wolf
authored
Merge pull request #15 from SiLab-Bonn/development
Development
2 parents 2d23376 + 0441392 commit 1f2af06

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ jobs:
1818
# This workflow contains a single job called "build"
1919
tests:
2020
name: Testing on Python ${{matrix.python-version}} | ${{matrix.sim}}
21-
runs-on: ubuntu-20.04
21+
runs-on: ubuntu-latest
2222

2323
strategy:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu-20.04, ubuntu-latest]
27-
python-version: [3.7, 3.8, 3.9]
27+
python-version: ["3.7", "3.10", "3.11"]
2828

2929
# Steps represent a sequence of tasks that will be executed as part of the job
3030
steps:

irrad_spectroscopy/spectroscopy.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@
66

77
# Imports
88
import logging
9-
import inspect
109
import warnings
1110
import numpy as np
1211
import irrad_spectroscopy as isp
1312
from irrad_spectroscopy.spec_utils import get_isotope_info, source_to_dict
1413
from irrad_spectroscopy.physics import decay_law, gamma_dose_rate
15-
from collections import OrderedDict, Iterable
14+
from collections import OrderedDict
15+
from collections.abc import Iterable
1616
from scipy.optimize import curve_fit, fsolve, OptimizeWarning
1717
from scipy.integrate import quad
1818
from scipy.interpolate import interp1d
1919

20+
# Fix for Python >= 3.11
21+
try:
22+
from inspect import getfullargspec as get_args
23+
except ImportError:
24+
from inspect import getargspec as get_args
25+
2026

2127
# set logging level when doing import
2228
logging.getLogger().setLevel(logging.INFO)
@@ -248,7 +254,7 @@ def interpolate_bkg(counts, channels=None, window=5, order=3, scale=0.5, energy_
248254
dy_mv_avg = [np.mean(dy_mv_avg[i:i + (window * (order - o))]) for i in range(dy.shape[0])]
249255

250256
# make mask
251-
bkg_mask = np.append(np.abs(dy_mv_avg) <= scale * np.mean(np.abs(dy_mv_avg)), np.array([0], dtype=np.bool))
257+
bkg_mask = np.append(np.abs(dy_mv_avg) <= scale * np.mean(np.abs(dy_mv_avg)), np.array([0], dtype=bool))
252258

253259
# interpolate the masked array into array, then create function and append to estimates
254260
bkg_estimates.append(interp1d(_chnnls, np.interp(_chnnls, _chnnls[bkg_mask], _cnts[bkg_mask]), kind='quadratic'))
@@ -371,7 +377,7 @@ def fit_spectrum(counts, channels=None, bkg=None, local_bkg=True, n_peaks=None,
371377
# boolean masks
372378
# masking regions due to failing general conditions (peak_mask)
373379
# masking successfully fitted regions (peak_mask_fitted)
374-
peak_mask, peak_mask_fitted = np.ones_like(_cnts, dtype=np.bool), np.ones_like(_cnts, dtype=np.bool)
380+
peak_mask, peak_mask_fitted = np.ones_like(_cnts, dtype=bool), np.ones_like(_cnts, dtype=bool)
375381

376382
# flag whether expected peaks have been checked
377383
checked_expected = False
@@ -528,7 +534,7 @@ def tmp_fit(x, *args):
528534
finally:
529535
k += .5
530536
_p0 = {'mu': _mu, 'sigma': _sigma, 'h': y_peak}
531-
fit_args = inspect.getargspec(peak_fit)[0][1:]
537+
fit_args = get_args(peak_fit)[0][1:]
532538
p0 = tuple(_p0[arg] if arg in _p0 else 1 for arg in fit_args)
533539
popt, pcov = curve_fit(tmp_fit, x_fit, y_fit, p0=p0, sigma=np.sqrt(y_fit), absolute_sigma=True, maxfev=5000)
534540
perr = np.sqrt(np.diag(pcov)) # get std deviation

0 commit comments

Comments
 (0)