Skip to content

Commit

Permalink
Add pre-commit, fix typing and linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkoehler committed Feb 14, 2024
1 parent 8b1cd22 commit f0ecdfe
Show file tree
Hide file tree
Showing 16 changed files with 198 additions and 91 deletions.
46 changes: 20 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
name: Tests
on:
push:
branches:
- main
- '*.x'
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
- '*.txt'
pull_request:
branches:
- main
- '*.x'
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
- '*.txt'
on: [push, pull_request]
jobs:
tests:
name: ${{ matrix.name }}
Expand All @@ -26,12 +8,22 @@ jobs:
fail-fast: false
matrix:
include:
- {name: 3.10 Linux, python: '3.10', os: ubuntu-latest, tox: py310}
- {name: 3.10 Windows, python: '3.10', os: windows-latest, tox: py310}
- {name: 3.10 Mac, python: '3.10', os: macos-latest, tox: py310}
- {name: Lint, python: '3.10', os: ubuntu-latest, tox: lint}
- {name: Typing, python: '3.10', os: ubuntu-latest, tox: typing}
- {name: Style, python: '3.10', os: ubuntu-latest, tox: style}
# - { name: 3.12 Linux, python: "3.12", os: ubuntu-latest, tox: py312 }
# - { name: 3.11 Linux, python: "3.11", os: ubuntu-latest, tox: py311 }
# - { name: 3.10 Linux, python: "3.10", os: ubuntu-latest, tox: py310 }
# - {
# name: 3.12 Windows,
# python: "3.12",
# os: windows-latest,
# tox: py312,
# }
# - { name: 3.12 Mac, python: "3.12", os: macos-latest, tox: py312 }
- {
name: Pre-commit,
python: "3.12",
os: ubuntu-latest,
tox: pre-commit,
}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand All @@ -47,6 +39,8 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }}
key:
pip|${{ runner.os }}|${{ matrix.python }}|${{
hashFiles('setup.py')}}
- run: pip install tox
- run: tox -e ${{ matrix.tox }}
91 changes: 91 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.10.1"
hooks:
- id: black-jupyter

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
# - id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: "v3.0.3"
# hooks:
# - id: prettier
# types_or: [yaml, markdown, html, css, scss, javascript, json]
# args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.3"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.6.1"
hooks:
- id: mypy
files: src|tests
args: []
additional_dependencies:
- pytest
- pandas-stubs

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: codespell

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
hooks:
- id: shellcheck

- repo: local
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
62 changes: 37 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
[![Python Versions][python-shield]][python-url]
[![PyPi][pypi-shield]][pypi-url]
[![Tests][tests-shield]][tests-url]
[![License][license-shield]][license-url]
[![Python Versions][python-shield]][python-url] [![PyPi][pypi-shield]][pypi-url]
[![Tests][tests-shield]][tests-url] [![License][license-shield]][license-url]
[![Contributors][contributors-shield]][contributors-url]
[![Code Style][codestyle-shield]][codestyle-url]
[![Homepage][homepage-shield]][homepage-url]


# PTE Stats - Python tools for electrophysiology

PTE Stats is an open-source software package for statistics with time series.

It builds upon [PTE](https://github.com/richardkoehler/pte) and provides statistical tools for time-series.
PTE Stats is particularly useful with intracranial EEG (iEEG) data such as local field potentials (LFP) and electrocorticography (ECoG).
It builds upon [PTE](https://github.com/richardkoehler/pte) and provides
statistical tools for time-series. PTE Stats is particularly useful with
intracranial EEG data such as local field potentials and electrocorticography.

## Installing pte-stats

Expand All @@ -26,7 +24,7 @@ $ pip install pte-stats

### Development version

To install the latest delevopment version, first clone this repository:
To install the latest development version, first clone this repository:

```bash
$ git clone https://github.com/richardkoehler/pte-stats
Expand All @@ -45,25 +43,27 @@ If you want to install pte-stats into an existing environment, type:
$ pip install -e .
```


## Usage

```python
import pte_stats

# Examples coming soon
```

## Contributing

Please feel free to contribute yourselves or to open an **issue** when you encounter a bug or to request a new feature.
Please feel free to contribute yourselves or to open an **issue** when you
encounter a bug or to request a new feature.

For any minor additions or bugfixes, you may simply create a **pull request**.
For any minor additions or bugfixes, you may simply create a **pull request**.

For any major changes, make sure to open an **issue** first. When you then create a pull request, be sure to **link the pull request** to the open issue in order to close the issue automatically after merging.
For any major changes, make sure to open an **issue** first. When you then
create a pull request, be sure to **link the pull request** to the open issue in
order to close the issue automatically after merging.

### How to contribute
To contribute yourselves, you should fork this repository, and then create a development branch from your fork.

To contribute yourselves, you should fork this repository, and then create a
development branch from your fork.

Then, inside your development branch run the commands:

Expand All @@ -78,24 +78,36 @@ $ conda activate pte-stats-dev
$ pip install -e .[dev]
```

This will additionally install packages for development, such as black, pylint, mypy and isort.
This will additionally install packages for development, such as black, pylint,
mypy and isort.

## License

PTE Stats is licensed under the [MIT license](license-url).

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[python-shield]: https://img.shields.io/static/v1?label=Python&message=3.10&logoColor=black&labelColor=grey&color=blue

[python-shield]:
https://img.shields.io/static/v1?label=Python&message=3.10&logoColor=black&labelColor=grey&color=blue
[python-url]: https://pypi.org/project/pte-stats/
[pypi-shield]: https://img.shields.io/static/v1?label=PyPi&message=v0.2.0&logoColor=black&labelColor=grey&color=blue
[pypi-shield]:
https://img.shields.io/static/v1?label=PyPi&message=v0.2.0&logoColor=black&labelColor=grey&color=blue
[pypi-url]: https://pypi.org/project/pte-stats/
[tests-shield]: https://github.com/richardkoehler/pte-stats/actions/workflows/tests.yml/badge.svg
[tests-url]: https://github.com/richardkoehler/pte-stats/actions/workflows/tests.yml
[homepage-shield]: https://img.shields.io/static/v1?label=Homepage&message=ICN&logoColor=black&labelColor=grey&color=9cf
[tests-shield]:
https://github.com/richardkoehler/pte-stats/actions/workflows/tests.yml/badge.svg
[tests-url]:
https://github.com/richardkoehler/pte-stats/actions/workflows/tests.yml
[homepage-shield]:
https://img.shields.io/static/v1?label=Homepage&message=ICN&logoColor=black&labelColor=grey&color=9cf
[homepage-url]: https://www.icneuromodulation.org/
[contributors-shield]: https://img.shields.io/github/contributors/richardkoehler/pte-stats.svg
[contributors-url]: https://github.com/richardkoehler/pte-stats/graphs/contributors
[license-shield]: https://img.shields.io/static/v1?label=License&message=MIT&logoColor=black&labelColor=grey&color=yellow
[contributors-shield]:
https://img.shields.io/github/contributors/richardkoehler/pte-stats.svg
[contributors-url]:
https://github.com/richardkoehler/pte-stats/graphs/contributors
[license-shield]:
https://img.shields.io/static/v1?label=License&message=MIT&logoColor=black&labelColor=grey&color=yellow
[license-url]: https://github.com/richardkoehler/pte-stats/blob/main/LICENSE/
[codestyle-shield]: https://img.shields.io/static/v1?label=CodeStyle&message=black&logoColor=black&labelColor=grey&color=black
[codestyle-shield]:
https://img.shields.io/static/v1?label=CodeStyle&message=black&logoColor=black&labelColor=grey&color=black
[codestyle-url]: https://github.com/psf/black
14 changes: 11 additions & 3 deletions doc/CHANGELOG.md → docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

### Fixed

### Changed

### Deprecated
### Removed

### Removed

## [0.1.0] - 2022-02-01

### Added

- Initial release

[Unreleased]: https://github.com/richardkoehler/pte-stats
[Unreleased]: https://github.com/richardkoehler/pte-stats
4 changes: 2 additions & 2 deletions env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ channels:
- defaults
dependencies:
- pip
- python=3.10
- python>=3.10
- pip:
- pte-stats
- pte-stats
5 changes: 2 additions & 3 deletions env_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ channels:
- defaults
dependencies:
- pip
- python=3.10
- python>=3.10
- pip:
- pte-stats[dev]

- -e .[dev]
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ confidence=
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.10"

dependencies = [
"joblib",
"numba",
"numpy",
"scikit-image",
Expand All @@ -35,10 +36,13 @@ dev = [
"black",
"isort",
"mypy",
"pandas-stubs",
"pip-tools",
"pre-commit",
"pylint",
"pytest",
"pytest-cov",
"ruff",
"tox",
]

Expand Down Expand Up @@ -67,7 +71,11 @@ line-length = 79
[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
"joblib",
"numba",
"numpy",
"scipy",
"scipy.stats",
"skimage",
"statsmodels.stats.multitest",
]
2 changes: 1 addition & 1 deletion requirements/requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numba
numpy
scikit-image
statsmodels
statsmodels
2 changes: 1 addition & 1 deletion requirements/requirements_deploy.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-c requirements.txt
-c requirements_dev.txt
flit
flit
2 changes: 1 addition & 1 deletion requirements/requirements_dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pip-tools
pylint
pytest
pytest-cov
tox
tox
Loading

0 comments on commit f0ecdfe

Please sign in to comment.