Skip to content

Commit

Permalink
Enh/add doctest runner (NeuralEnsemble#503)
Browse files Browse the repository at this point in the history
* fixed asset doctest formatting

* fixed doctests in granger.py

* fixed granger doctest np.random.seed

* fix datasets.py example

* fixed doctests in gpfa.py

* fix doctest signal_processing.py

* display plot from elephant.signal_processing.cross_correlation_function

* display plot from elephant.signal_processing.hilbert¶

* fix doctest spade.py

* update spade doctests

* doctest fix fast_fca.py

* fix doctest spectral.py

* fix doctest spike_train_correlation.py

* doctest for spike_train_correlation.py

* doctest for spike_train_surrogates.py

* fixed doctests in spike_train_synchrony.py

* fixed doctests in statistics.py

* doctest for spike_train_synchrony.py

* fixed doctests in sta.py

* display figure in elephant.sta.spike_field_coherence

* fix doctests statistics.py

* changes in test_sta.py

* fixed doctests in unitary_event_analysis.py

* fix doctests unitary_event_analysis.py

* signal_processing.py old results

* fix pep8 in spade.py

* add doctest runner

* add mpi4py to doctest runner

* change installation order

* install openmpi library

* remove trailing spaces from CI.yml

* add doctest runner

* add mpi4py to doctest runner

* change installation order

* install openmpi library

* remove trailing spaces from CI.yml

* Revert "remove trailing spaces from CI.yml"

This reverts commit bd833ed.

* Revert "install openmpi library"

This reverts commit b9eefef.

* Revert "change installation order"

This reverts commit 8671d61.

* Revert "add mpi4py to doctest runner"

This reverts commit 55709b5.

* Revert "add doctest runner"

This reverts commit 80de439.

* skip doctest cell_assembly_detection.py

* skip doctest change_point_detection.py

* skip second doctest change_point_detection.py

* skip second doctest cubic.py

* skip second doctest phase_analysis.py

* skip second doctest signal_processing.py

* skip second doctest spade.py

* skip doctest spike_train_correlation.py

* skip doctest spike_train_surrogates.py

* skip doctest statistics.py

* skip doctest change_point_detection.py

* skip doctest spike_train_correlation.py

* skip doctest spike_train_surrogates.py

* skip doctest statistics.py

* skip doctest unitary_event_analysis.py

* fix pep8
  • Loading branch information
Moritz-Alexander-Kern committed Feb 16, 2023
1 parent b6f8440 commit 06e0cd1
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,65 @@ jobs:
activate base
cd doc
make html
# install dependencies and elephant with pip and run tests with pytest
doctests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.7, 3.8, 3.9, "3.10"]
python-version: ["3.10"]

# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]

# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false

steps:
# used to reset cache every month
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Cache test_env
uses: actions/cache@v3
with:
path: ~/test_env
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }}
-${{ steps.date.outputs.date }}

- name: Install dependencies
run: |
# create an environment and install everything
python -m venv ~/test_env
source ~/test_env/bin/activate
sudo apt install -y libopenmpi-dev openmpi-bin
python -m pip install --upgrade pip
pip install mpi4py
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: List packages
run: |
source ~/test_env/bin/activate
pip list
python --version
- name: Run doctests
run: |
source ~/test_env/bin/activate
pytest elephant --doctest-modules --ignore=elephant/test/
19 changes: 16 additions & 3 deletions elephant/spade.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@
>>> patterns = spade(spiketrains, bin_size=10 * pq.ms, winlen=1,
... dither=5 * pq.ms, min_spikes=6, n_surr=10,
... psr_param=[0, 0, 3])['patterns']
>>> patterns[0]
... psr_param=[0, 0, 3])['patterns'] # doctest:+ELLIPSIS
Time for data mining: ...
Time for pvalue spectrum computation: ...
>>> patterns[0] # doctest: +SKIP
{'itemset': (4, 3, 0, 2, 5, 1),
'windows_ids': (9,
16,
Expand Down Expand Up @@ -314,9 +317,19 @@ def spade(spiketrains, bin_size, winlen, min_spikes=2, min_occ=2,
>>> from elephant.spade import spade
>>> import quantities as pq
>>> from elephant.spike_train_generation import compound_poisson_process
>>> np.random.seed(30)
>>> spiketrains = compound_poisson_process(rate=15*pq.Hz,
... amplitude_distribution=[0, 0.95, 0, 0, 0, 0, 0.05], t_stop=5*pq.s)
>>> bin_size = 3 * pq.ms # time resolution to discretize the spiketrains
>>> winlen = 10 # maximal pattern length in bins (i.e., sliding window)
>>> result_spade = spade(spiketrains, bin_size, winlen)
>>> result_spade = spade(
... spiketrains, bin_size, winlen) # doctest: +ELLIPSIS
Time for data mining: ...
"""
if HAVE_MPI: # pragma: no cover
Expand Down

0 comments on commit 06e0cd1

Please sign in to comment.