Skip to content

Commit

Permalink
style: fix doc lints, introduce ruff linting
Browse files Browse the repository at this point in the history
  • Loading branch information
asoplata committed Nov 8, 2024
1 parent 2e79a5a commit c3da09a
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/unix_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
shell: bash -el {0}
run: |
pip install --verbose '.[opt, parallel, test, gui]'
- name: Lint with ruff
shell: bash -el {0}
run: |
ruff check --no-fix
- name: Check formatting with ruff
shell: bash -el {0}
run: |
ruff format --check
- name: Test with pytest
shell: bash -el {0}
run: |
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ check-manifest:
format:
ruff format

lint:
ruff check

modl:
cd hnn_core/mod/ && nrnivmodl

test:
ruff format --check
ruff check --no-fix
pytest .
1 change: 0 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import sys

# sys.path.insert(0, os.path.abspath('.'))
import sphinx_gallery
from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder

import sphinx_bootstrap_theme
Expand Down
2 changes: 0 additions & 2 deletions examples/howto/plot_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

# sphinx_gallery_thumbnail_number = 2

import os.path as op

###############################################################################
# Let us import ``hnn_core``.

import hnn_core
from hnn_core import jones_2009_model, simulate_dipole

###############################################################################
Expand Down
1 change: 0 additions & 1 deletion examples/howto/plot_firing_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
###############################################################################
# Let us import ``hnn_core``.

import hnn_core
from hnn_core import read_spikes, jones_2009_model, simulate_dipole

###############################################################################
Expand Down
4 changes: 1 addition & 3 deletions examples/howto/plot_hnn_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
###############################################################################
# First, we'll import the necessary modules for instantiating a network and
# running a simulation that we would like to animate.
import os.path as op

import hnn_core
from hnn_core import jones_2009_model, simulate_dipole, read_params
from hnn_core import jones_2009_model, simulate_dipole
from hnn_core.network_models import add_erp_drives_to_jones_model

###############################################################################
Expand Down
2 changes: 0 additions & 2 deletions examples/howto/plot_simulate_mpi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

###############################################################################
# Let us import hnn_core
import os.path as op

import hnn_core
from hnn_core import simulate_dipole, jones_2009_model

###############################################################################
Expand Down
4 changes: 1 addition & 3 deletions examples/workflows/plot_simulate_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
# Nick Tolley <[email protected]>
# Christopher Bailey <[email protected]>

import os.path as op

###############################################################################
# Let us import hnn_core

import hnn_core
from hnn_core import simulate_dipole, jones_2009_model

###############################################################################
Expand Down Expand Up @@ -72,7 +70,7 @@
# included in our biophysical model. We can confirm that what we simulate is
# indeed 10 Hz activity by plotting the power spectral density (PSD).
import matplotlib.pyplot as plt
from hnn_core.viz import plot_dipole, plot_psd
from hnn_core.viz import plot_psd

fig, axes = plt.subplots(2, 1, constrained_layout=True)
tmin, tmax = 10, 300 # exclude the initial burn-in period from the plots
Expand Down
5 changes: 0 additions & 5 deletions examples/workflows/plot_simulate_evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@

# sphinx_gallery_thumbnail_number = 3

import os.path as op
import tempfile

import matplotlib.pyplot as plt

###############################################################################
# Let us import hnn_core

import hnn_core
from hnn_core import simulate_dipole, jones_2009_model
from hnn_core.viz import plot_dipole

Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ ignore-words-list = 'tha,nam,sherif,dout'
exclude = ["*.ipynb"]
[tool.ruff.format]
quote-style = "single"
[tool.ruff.lint]
exclude = ["__init__.py"]
# We don't include rule "W504", which was in our old flake8 "setup.cfg" file for 2 reasons: it is an
# invalid option for the ruff linter, and the ruff formatter already applies that rule.
ignore = [
"E402", # Needed for notes at beginning of example scripts
"E722", # From original flake8 'setup.cfg' file, needed in viz.py
]

0 comments on commit c3da09a

Please sign in to comment.