Skip to content

Commit ac12d71

Browse files
authored
[MAINT] Fix tests and update Python to >=3.9 (#95)
1 parent ba2d037 commit ac12d71

6 files changed

Lines changed: 14 additions & 7 deletions

File tree

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
max-parallel: 4
1616
matrix:
17-
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1818

1919
steps:
2020
- uses: actions/checkout@v4

meegkit/utils/asr.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ def fit_eeg_distribution(X, min_clean_fraction=0.25, max_dropout_fraction=0.1,
158158
# calculate the distribution's standard deviation from alpha and beta
159159
sig = np.sqrt((alpha ** 2) * gamma(3 / beta) / gamma(1 / beta))
160160

161+
# Ensure scalar values are returned (extract from arrays if needed)
162+
alpha = float(np.asarray(alpha).squeeze())
163+
mu = float(np.asarray(mu).squeeze())
164+
sig = float(np.asarray(sig).squeeze())
165+
161166
return mu, sig, alpha, beta
162167

163168

@@ -432,7 +437,8 @@ def numf(h, a, nb):
432437
toeplitz(impr, np.concatenate((1, np.zeros((1, nb))), axis=None)),
433438
h.T, rcond=None)[0].T
434439

435-
return b
440+
# Ensure 1D array is returned
441+
return np.atleast_1d(b.squeeze())
436442

437443

438444
def denf(R, na):

meegkit/utils/sig.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ def prony(h, nb, na):
612612

613613
# K-M by N
614614
a_right = np.linalg.lstsq(-H2, h1, rcond=None)[0]
615-
a = np.r_[(np.array([1]), a_right)][None, :]
615+
a = np.r_[(np.array([1]), a_right)]
616616
b = np.dot(np.dot(c, a), H1.T)
617-
return b, a
617+
# Ensure 1D arrays are returned
618+
return np.atleast_1d(b.squeeze()), np.atleast_1d(a.squeeze())

meegkit/utils/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def snr_spectrum(X, freqs, n_avg=1, n_harm=1, skipbins=1):
385385

386386
# Ratio
387387
with np.errstate(divide="ignore", invalid="ignore"):
388-
SNR[i_bin, i_trial] = np.sqrt(A) / np.sqrt(B)
388+
SNR[i_bin, i_trial] = np.sqrt(A) / np.sqrt(np.mean(B))
389389

390390
del A
391391
del B

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = {text = "BSD (3-clause)"}
1212
dynamic = ["version", "dependencies"]
1313
description = "M/EEG denoising in Python"
1414
readme = {file = "README.md", content-type = "text/markdown"}
15-
requires-python = ">=3.8"
15+
requires-python = ">=3.9"
1616

1717
[project.urls]
1818
homepage = "https://nbara.github.io/python-meegkit"

tests/test_asr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_asr_class(method, reref, show=False):
189189

190190
if reref:
191191
if method == "riemann":
192-
with pytest.raises(ValueError, match="Add regularization"):
192+
with pytest.raises(ValueError, match="add regularization"):
193193
blah = ASR(method=method, estimator="scm")
194194
blah.fit(raw2[:, train_idx])
195195

0 commit comments

Comments
 (0)