Skip to content

Commit

Permalink
min py3.8 & update with Ruff (#6)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Borda and pre-commit-ci[bot] authored Jun 5, 2024
1 parent 971204a commit 70217dd
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macOS-11, windows-latest]
python-version: ["3.7", "3.9"]
os: ["ubuntu-22.04", "macOS-13", "windows-2022"]
python-version: ["3.8", "3.9"]

# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 10
Expand Down
23 changes: 9 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -19,26 +19,21 @@ repos:
- id: detect-private-key

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gfm
- mdformat-black
- mdformat_frontmatter

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
name: Format code
args:
- "--line-length=120"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
rev: v0.4.8
hooks:
# try to fix what is possible
- id: ruff
args: ["--fix"]
# perform formatting updates
- id: ruff-format
# validate if all is fine with preview mode
- id: ruff
args:
- "--fix"
- "--line-length=120"
2 changes: 2 additions & 0 deletions gammatone/fftweight.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
This module contains functions for calculating weights to approximate a
gammatone filterbank-like "spectrogram" from a Fourier transform.
"""

from __future__ import division

import numpy as np

import gammatone.filters as filters
Expand Down
1 change: 1 addition & 0 deletions gammatone/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This module contains functions for constructing sets of equivalent rectangular
bandwidth gammatone filters.
"""

from __future__ import division

import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion gammatone/gtgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"""

from __future__ import division

import numpy as np

from .filters import make_erb_filters, centre_freqs, erb_filterbank
from .filters import centre_freqs, erb_filterbank, make_erb_filters


def round_half_away_from_zero(num):
Expand Down
7 changes: 5 additions & 2 deletions gammatone/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
Plotting utilities related to gammatone analysis, primarily for use with
``matplotlib``.
"""

from __future__ import division

import argparse
import os.path

Expand All @@ -16,9 +18,10 @@
import scipy.constants
import scipy.io.wavfile

from .filters import erb_point
import gammatone.gtgram
import gammatone.fftweight
import gammatone.gtgram

from .filters import erb_point


class ERBFormatter(matplotlib.ticker.EngFormatter):
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
requires = [
"setuptools",
"wheel",
]

[tool.ruff]
target-version = "py38"
line-length = 120

#[tool.ruff.format]
#preview = true

[tool.ruff.lint]
select = [
"E",
"W", # see: https://pypi.org/project/pycodestyle
"F", # see: https://pypi.org/project/pyflakes
"I", #see: https://pypi.org/project/isort/
# "D", # see: https://pypi.org/project/pydocstyle
# "N", # see: https://pypi.org/project/pep8-naming
# "S", # see: https://pypi.org/project/flake8-bandit
# "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
]
ignore = [
"E731", # Do not assign a lambda expression, use a def
]
ignore-init-module-imports = true
unfixable = ["F401"]

[tool.ruff.lint.pydocstyle]
# Use Google-style docstrings.
convention = "google"

#[tool.ruff.pycodestyle]
#ignore-overlong-task-comments = true

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# BSD license: https://github.com/detly/gammatone/blob/master/COPYING
import os

from setuptools import setup, find_packages
from setuptools import find_packages, setup

_PATH_ROOT = os.path.dirname(__file__)

with open(os.path.join(_PATH_ROOT, "README.md"), encoding="utf-8") as fo:
readme = fo.read()
README = fo.read()

setup(
name="Gammatone",
Expand All @@ -18,7 +18,8 @@
author_email="[email protected]",
url="https://github.com/Lightning-Sandbox/gammatone",
download_url="https://github.com/Lightning-Sandbox/gammatone/archive/master.zip",
long_description=readme,
long_description=README,
python_requires=">=3.8",
long_description_content_type="text/markdown",
packages=find_packages(exclude=["tests"]),
install_requires=["numpy", "scipy", "matplotlib"],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fft_gtgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#
# This file is part of the gammatone toolkit, and is licensed under the 3-clause
# BSD license: https://github.com/detly/gammatone/blob/master/COPYING
from mock import patch
import nose
import numpy as np
import scipy.io
from mock import patch
from pkg_resources import resource_stream

import gammatone.fftweight
Expand Down
1 change: 1 addition & 0 deletions tests/test_fft_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This file is part of the gammatone toolkit, and is licensed under the 3-clause
# BSD license: https://github.com/detly/gammatone/blob/master/COPYING
from __future__ import division

import nose
import numpy as np
import scipy.io
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gammatonegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#
# This file is part of the gammatone toolkit, and is licensed under the 3-clause
# BSD license: https://github.com/detly/gammatone/blob/master/COPYING
from mock import patch
import nose
import numpy as np
import scipy.io
from mock import patch
from pkg_resources import resource_stream

import gammatone.gtgram
Expand Down
2 changes: 1 addition & 1 deletion tests/test_specgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#
# This file is part of the gammatone toolkit, and is licensed under the 3-clause
# BSD license: https://github.com/detly/gammatone/blob/master/COPYING
from mock import patch
import nose
import numpy as np
import scipy.io
from mock import patch
from pkg_resources import resource_stream

import gammatone.fftweight
Expand Down

0 comments on commit 70217dd

Please sign in to comment.