Skip to content

Commit e78c683

Browse files
author
Cristiano Köhler
committed
Merge branch 'master' into enh/trial_by_trial_methods
2 parents 38ca75c + 066c48d commit e78c683

File tree

5 files changed

+57
-43
lines changed

5 files changed

+57
-43
lines changed

.github/workflows/CI.yml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
fail-fast: false
135135
matrix:
136136
# OS [ubuntu-latest, macos-latest, windows-latest]
137-
os: [macos-13,macos-14]
137+
os: [macos-14,macos-15]
138138
python-version: [3.12]
139139
steps:
140140
- name: Get current year-month
@@ -143,6 +143,17 @@ jobs:
143143

144144
- uses: actions/[email protected]
145145

146+
- name: Set up Python ${{ matrix.python-version }}
147+
uses: actions/[email protected]
148+
with:
149+
python-version: ${{ matrix.python-version }}
150+
check-latest: true
151+
cache: 'pip'
152+
cache-dependency-path: |
153+
**/requirements.txt
154+
**/requirements-extras.txt
155+
**/requirements-tests.txt
156+
146157
- name: Get current hash (SHA) of the elephant_data repo
147158
id: elephant-data
148159
run: |
@@ -157,11 +168,11 @@ jobs:
157168
restore-keys: datasets-
158169

159170
- name: Install dependencies
160-
shell: bash -l {0}
161171
run: |
162172
python --version
163-
pip install -e .[extras,tests]
173+
python -m pip install --upgrade pip
164174
pip install pytest-cov coveralls
175+
pip install -e .[extras,tests]
165176
166177
- name: List packages
167178
shell: bash -l {0}
@@ -366,29 +377,24 @@ jobs:
366377
restore-keys: datasets-
367378
enableCrossOsArchive: true
368379

369-
- uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # corresponds to v3.1.0
380+
- uses: mamba-org/setup-micromamba@v2
370381
with:
371-
auto-update-conda: true
372-
python-version: ${{ matrix.python-version }}
373-
mamba-version: "*"
374-
channels: conda-forge
375-
channel-priority: true
376-
activate-environment: elephant
382+
create-args: python=${{ matrix.python-version }}
377383
environment-file: requirements/environment-tests.yml
378-
conda-remove-defaults: true
384+
init-shell: bash
379385

380386
- name: Install dependencies
381387
shell: bash -el {0}
382388
run: |
383389
python --version
384-
mamba install -c conda-forge pytest pytest-cov coveralls mpi4py openmpi
390+
micromamba install -y -c conda-forge pytest pytest-cov coveralls mpi4py openmpi
385391
pip install -e .
386392
387393
- name: List packages
388394
shell: bash -el {0}
389395
run: |
390396
pip list
391-
mamba list
397+
micromamba list
392398
python --version
393399
394400
- name: Test with pytest
@@ -438,23 +444,20 @@ jobs:
438444
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-docs.txt') }}-${{ hashFiles('**/requirements-tutorials.txt') }}-${{ hashFiles('**/environment-docs.yml') }}
439445
-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
440446

441-
- uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # corresponds to v3.1.0
447+
- uses: mamba-org/setup-micromamba@v2
442448
with:
443-
auto-update-conda: true
444-
python-version: ${{ matrix.python-version }}
445-
mamba-version: "*"
446-
activate-environment: elephant
449+
create-args: python=${{ matrix.python-version }}
447450
environment-file: requirements/environment.yml
448-
conda-remove-defaults: true
451+
init-shell: bash
449452

450453
- name: Install dependencies
451-
shell: bash -el {0} # enables conda incubator to activate environment
454+
shell: bash -el {0}
452455
run: |
453456
sudo apt-get update
454457
sudo apt install -y libopenmpi-dev openmpi-bin
455458
456-
mamba install -c conda-forge openmpi pandoc libstdcxx-ng # fix libstdc++.so.6: version for new scipy versions > 1.9.1
457-
mamba env update --file requirements/environment-docs.yml --name elephant
459+
micromamba install -y -c conda-forge openmpi pandoc libstdcxx-ng # fix libstdc++.so.6: version for new scipy versions > 1.9.1
460+
micromamba env update --file requirements/environment-docs.yml --name elephant
458461
python -m pip install --upgrade pip
459462
pip install -e .[extras,tutorials,docs]
460463
# run notebooks
@@ -464,7 +467,7 @@ jobs:
464467
shell: bash -el {0}
465468
run: |
466469
pip list
467-
mamba list
470+
micromamba list
468471
python --version
469472
470473
- name: make html

.github/workflows/build_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [ubuntu-20.04, windows-2019]
18+
os: [ubuntu-latest, windows-latest]
1919

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

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Elephant - Electrophysiology Analysis Toolkit
22

33
[![Coverage Status](https://coveralls.io/repos/github/NeuralEnsemble/elephant/badge.svg?branch=master)](https://coveralls.io/github/NeuralEnsemble/elephant?branch=master)
4+
[![Test Status](https://github.com/NeuralEnsemble/elephant/actions/workflows/CI.yml/badge.svg)](https://github.com/NeuralEnsemble/elephant/actions/workflows/CI.yml)
45
[![Documentation Status](https://readthedocs.org/projects/elephant/badge/?version=latest)](https://elephant.readthedocs.io/en/latest/?badge=latest)
5-
[![![PyPi]](https://img.shields.io/pypi/v/elephant)](https://pypi.org/project/elephant/)
6-
[![Statistics](https://img.shields.io/pypi/dm/elephant)](https://seladb.github.io/StarTrack-js/#/preload?r=neuralensemble,elephant)
7-
[![Gitter](https://badges.gitter.im/python-elephant/community.svg)](https://gitter.im/python-elephant/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6+
[![![PyPi] Status](https://img.shields.io/pypi/v/elephant)](https://pypi.org/project/elephant/)
87
[![DOI Latest Release](https://zenodo.org/badge/10311278.svg)](https://zenodo.org/badge/latestdoi/10311278)
9-
[![tests](https://github.com/NeuralEnsemble/elephant/actions/workflows/CI.yml/badge.svg)](https://github.com/NeuralEnsemble/elephant/actions/workflows/CI.yml)
10-
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6191/badge)](https://bestpractices.coreinfrastructure.org/projects/6191)
11-
[![fair-software.eu](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green)](https://fair-software.eu)
8+
[![Download Statistics](https://img.shields.io/pypi/dm/elephant)](https://seladb.github.io/StarTrack-js/#/preload?r=neuralensemble,elephant)<br>
9+
[![Chat on Gitter](https://badges.gitter.im/python-elephant/community.svg)](https://gitter.im/python-elephant/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1210
[![Follow me on Bluesky](https://img.shields.io/badge/Bluesky-0285FF?logo=bluesky&logoColor=fff&label=Follow%20me%20on&color=0285FF)](https://bsky.app/profile/pyelephant.bsky.social)
13-
[![Fosstodon](https://img.shields.io/badge/@elephant-6364FF?logo=mastodon&logoColor=fff&style=flat)](https://fosstodon.org/@elephant)
11+
[![Follow me on Fosstodon](https://img.shields.io/badge/@elephant-6364FF?logo=mastodon&logoColor=fff&style=flat)](https://fosstodon.org/@elephant)<br>
12+
[![fair-software.eu](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green)](https://fair-software.eu)
13+
[![OpenSSF/CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6191/badge)](https://bestpractices.coreinfrastructure.org/projects/6191)
14+
[![JURSE Code Pick](https://img.shields.io/badge/JuRSE_Code_Pick-Nov_2025-blue)](https://www.fz-juelich.de/en/rse/community-initiatives/jurse-code-of-the-month/november-2025)
15+
![HiRSE Code Promo](https://img.shields.io/badge/Promo-8db427?label=HiRSE&labelColor=005aa0&link=https%3A%2F%2Fgo.fzj.de%2FCodePromo)
1416

1517

1618
*Elephant* package analyses all sorts of neurophysiological data:

elephant/test/test_signal_processing.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -448,31 +448,33 @@ def test_butter_filter_type(self):
448448
# this by using an identity function for detrending
449449
filtered_noise = elephant.signal_processing.butter(
450450
noise, 250.0 * pq.Hz, None)
451-
_, psd = spsig.welch(filtered_noise.T, nperseg=1024, fs=1000.0,
452-
detrend=lambda x: x)
451+
_, psd = spsig.welch(filtered_noise.magnitude.T,
452+
nperseg=1024, fs=1000.0, detrend=lambda x: x)
453453
self.assertAlmostEqual(psd[0, 0], 0)
454454

455455
# test low-pass filtering: power at the highest frequency
456456
# should be almost zero
457457
filtered_noise = elephant.signal_processing.butter(
458458
noise, None, 250.0 * pq.Hz)
459-
_, psd = spsig.welch(filtered_noise.T, nperseg=1024, fs=1000.0)
459+
_, psd = spsig.welch(filtered_noise.magnitude.T, nperseg=1024,
460+
fs=1000.0)
460461
self.assertAlmostEqual(psd[0, -1], 0)
461462

462463
# test band-pass filtering: power at the lowest and highest frequencies
463464
# should be almost zero
464465
filtered_noise = elephant.signal_processing.butter(
465466
noise, 200.0 * pq.Hz, 300.0 * pq.Hz)
466-
_, psd = spsig.welch(filtered_noise.T, nperseg=1024, fs=1000.0,
467-
detrend=lambda x: x)
467+
_, psd = spsig.welch(filtered_noise.magnitude.T, nperseg=1024,
468+
fs=1000.0, detrend=lambda x: x)
468469
self.assertAlmostEqual(psd[0, 0], 0)
469470
self.assertAlmostEqual(psd[0, -1], 0)
470471

471472
# test band-stop filtering: power at the intermediate frequency
472473
# should be almost zero
473474
filtered_noise = elephant.signal_processing.butter(
474475
noise, 400.0 * pq.Hz, 100.0 * pq.Hz)
475-
_, psd = spsig.welch(filtered_noise.T, nperseg=1024, fs=1000.0)
476+
_, psd = spsig.welch(filtered_noise.magnitude.T, nperseg=1024,
477+
fs=1000.0)
476478
self.assertAlmostEqual(psd[0, 256], 0)
477479

478480
def test_butter_filter_function(self):
@@ -493,17 +495,20 @@ def test_butter_filter_function(self):
493495
'lowpass_frequency': None, 'filter_function': 'filtfilt'}
494496
filtered_noise = elephant.signal_processing.butter(**kwds)
495497
_, psd_filtfilt = spsig.welch(
496-
filtered_noise.T, nperseg=1024, fs=1000.0, detrend=lambda x: x)
498+
filtered_noise.magnitude.T, nperseg=1024, fs=1000.0,
499+
detrend=lambda x: x)
497500

498501
kwds['filter_function'] = 'lfilter'
499502
filtered_noise = elephant.signal_processing.butter(**kwds)
500503
_, psd_lfilter = spsig.welch(
501-
filtered_noise.T, nperseg=1024, fs=1000.0, detrend=lambda x: x)
504+
filtered_noise.magnitude.T, nperseg=1024, fs=1000.0,
505+
detrend=lambda x: x)
502506

503507
kwds['filter_function'] = 'sosfiltfilt'
504508
filtered_noise = elephant.signal_processing.butter(**kwds)
505509
_, psd_sosfiltfilt = spsig.welch(
506-
filtered_noise.T, nperseg=1024, fs=1000.0, detrend=lambda x: x)
510+
filtered_noise.magnitude.T, nperseg=1024, fs=1000.0,
511+
detrend=lambda x: x)
507512

508513
self.assertAlmostEqual(psd_filtfilt[0, 0], psd_lfilter[0, 0])
509514
self.assertAlmostEqual(psd_filtfilt[0, 0], psd_sosfiltfilt[0, 0])

elephant/test/test_spectral.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ def test_welch_psd_behavior(self):
9797
for key, val in params.items():
9898
freqs, psd = elephant.spectral.welch_psd(
9999
data, len_segment=1000, overlap=0, **{key: val})
100-
freqs_spsig, psd_spsig = spsig.welch(np.rollaxis(data, 0, len(
101-
data.shape)), fs=1 / sampling_period, nperseg=1000,
102-
noverlap=0, **{key: val})
100+
freqs_spsig, psd_spsig = spsig.welch(
101+
np.rollaxis(data.magnitude, 0, len(data.shape)),
102+
fs=1 / sampling_period,
103+
nperseg=1000,
104+
noverlap=0,
105+
**{key: val}
106+
)
103107
self.assertTrue(
104108
(freqs == freqs_spsig).all() and (
105109
psd == psd_spsig).all())

0 commit comments

Comments
 (0)