Skip to content

Commit

Permalink
[MAINT] Run black, isort, ruff, and other auto-linters on entire pack…
Browse files Browse the repository at this point in the history
…age (mne-tools#159)

* Repackage with pyrpoject.toml

Signed-off-by: Adam Li <[email protected]>

* Fix CIs

Signed-off-by: Adam Li <[email protected]>

* Add version

Signed-off-by: Adam Li <[email protected]>

* Try to fix ci again

Signed-off-by: Adam Li <[email protected]>

* Fix the pyproject toml and otehr files

Signed-off-by: Adam Li <[email protected]>

* Fix circleCI and style

Signed-off-by: Adam Li <[email protected]>

* Fix statsmodels install

Signed-off-by: Adam Li <[email protected]>

* Run precommit

Signed-off-by: Adam Li <[email protected]>

* Ran black and isort and ruff

Signed-off-by: Adam Li <[email protected]>

* Sort pyrpoject

Signed-off-by: Adam Li <[email protected]>

* Fix

Signed-off-by: Adam Li <[email protected]>

* Don't need to test install

Signed-off-by: Adam Li <[email protected]>

---------

Signed-off-by: Adam Li <[email protected]>
  • Loading branch information
adam2392 authored Dec 6, 2023
1 parent 0738bb2 commit de48d25
Show file tree
Hide file tree
Showing 59 changed files with 4,597 additions and 2,912 deletions.
5 changes: 4 additions & 1 deletion .codespellignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
raison
fro
nd
nd
manuel
ba
master
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
- name: Run toml-sort
run: toml-sort pyproject.toml --check
- name: Run yamllint
run: yamllint . -c .yamllint.yaml --strict
run: yamllint . -c .yamllint.yml --strict
58 changes: 0 additions & 58 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,6 @@ on:
- "*"

jobs:
# Run installation tests
install:
runs-on: install-${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"]
include:
# An old one
- os: ubuntu-latest
python-version: "3.9"
steps:
- uses: actions/checkout@v4
- uses: pyvista/setup-headless-display-action@main
with:
qt: true
pyvista: false
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade .[test]
- run: mne sys_info
- name: Build sdist
run: python setup.py sdist
- name: Install sdist
run: pip install ./dist/mne-connectivity-*
shell: bash -e {0}
- name: Clean up working directory
run: rm -rf ./*
shell: bash -e {0}
- name: Try importing mne_connectivity
run: python -c 'import mne_connectivity; print(mne_connectivity.__version__)'
- name: Remove sdist install
run: pip uninstall -y mne-connectivity
# build with build wheet
- uses: actions/checkout@v4
- name: Build wheel
run: python setup.py bdist_wheel
- name: Install wheel
run: pip install ./dist/mne_connectivity-*.whl
shell: bash -e {0}
- name: Clean up working directory
run: rm -rf ./*
shell: bash -e {0}
- name: Try importing mne_connectivity
run: python -c 'import mne_connectivity; print(mne_connectivity.__version__)'
- name: Remove wheel install
run: pip uninstall -y mne-connectivity
- uses: actions/checkout@v4
- name: Test extras install
run: |
pip install .[full]
python -c 'import mne_connectivity; print(mne_connectivity.__version__)'
# Run unit tests
test:
runs-on: ${{ matrix.os }}
Expand Down
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
args: [--quiet]

# Ruff mne_connectivity
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
name: ruff mne_connectivity
args: ["--fix"]
files: ^mne_connectivity/

# Ruff tutorials and examples
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
name: ruff tutorials and examples
# D103: missing docstring in public function
# D400: docstring first line must end with period
args: ["--ignore=D103,D400", "--fix"]
files: ^tutorials/|^examples/

# Codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
files: ^mne_connectivity/|^doc/|^examples/|^tutorials/
types_or: [python, bib, rst, inc]

# yamllint
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
hooks:
- id: yamllint
args: [--strict, -c, .yamllint.yml]

# rstcheck
- repo: https://github.com/rstcheck/rstcheck.git
rev: v6.2.0
hooks:
- id: rstcheck
additional_dependencies:
- tomli
files: ^doc/.*\.(rst|inc)$

ci:
autofix_prs: false
File renamed without changes.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ First, you should [fork](https://help.github.com/en/github/getting-started-with-


### Install Python packages required to run tests
Install the following packages for testing purposes, plus all optonal MNE-connectivity
Install the following packages for testing purposes, plus all optional MNE-connectivity
dependencies to ensure you will be able to run all tests.

$ pip install -r requirements_testing.txt
$ pip install .[test]

### Invoke pytest
Now you can finally run the tests by running `pytest` in the
Expand All @@ -44,7 +44,7 @@ Now you can finally run the tests by running `pytest` in the
The documentation can be built using sphinx. For that, please additionally
install the following:

$ pip install -r requirements_doc.txt
$ pip install .[doc]

To build the documentation locally, one can run:

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/bench_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"""
import numpy as np
from memory_profiler import profile

from statsmodels.tsa.vector_ar.var_model import VAR

from mne_connectivity import vector_auto_regression


Expand All @@ -29,10 +29,10 @@ def run_sm_experiment(sample_data):
"""Run RAM expeirment with statsmodels."""
# statsmodels feeds in (n_samples, n_channels)
sm_var = VAR(endog=sample_data.squeeze().T)
sm_params = sm_var.fit(maxlags=5, trend='n')
sm_params = sm_var.fit(maxlags=5, trend="n")


if __name__ == '__main__':
if __name__ == "__main__":
rng = np.random.RandomState(0)
n_epochs, n_signals, n_times = 1, 50, 100
data = rng.randn(n_epochs, n_signals, n_times)
Expand Down
Loading

0 comments on commit de48d25

Please sign in to comment.