Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 refresh #181

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
name: black

name: ruff 'n' stuff
on: [pull_request]

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Black Code Formatter
uses: lgeiger/[email protected]
with:
args: ". --check"
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
# Update output format to enable automatic inline annotations.
- name: Run Ruff
run: ruff check --output-format=github .
2 changes: 1 addition & 1 deletion .github/workflows/check-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.11
- name: Generate coverage report
run: |
python -m pip install --upgrade pip
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/python-runlinter.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/python-runtests-basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/python-runtests-img-comp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .git,docs/*
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
export MPL_IMGCOMP_TOLERANCE=20
python check_wqio.py --strict
python check_wqio.py --strict --verbose
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
language_version: python3

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args:
- --py310-plus

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
name: absolufy-imports
5 changes: 1 addition & 4 deletions generate_vstasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@
configpath = configdir / "tasks.json"

python = str(Path(sys.executable))
if len(sys.argv) < 2:
name = Path.cwd().name
else:
name = sys.argv[1]
name = Path.cwd().name if len(sys.argv) < 2 else sys.argv[1]

config = TEMPLATE.format(pyexec=python, modulename=name)
with configpath.open("w") as configfile:
Expand Down
3 changes: 3 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ coverage
docopt
requests
pyyaml
ruff
pre-commit
isort
18 changes: 18 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
line-length = 100

[lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
## flake8-bugbear
# "B",
# flake8-simplify
"SIM",
]

[format]
indent-style = "space"
22 changes: 10 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
[metadata]
description-file = readme.rst

[tool:pytest]
pep8ignore =
E501
E131
check_wqio.py ALL
wqio/examples/* ALL
wqio/tests/* E501
wqio/tests/test_features.py E241
wqio/tests/test_datacollections.py E241
wqio/tests/test_ros.py E241
docs/* ALL

markers =
mpl_image_compare

[pep8]
max-line-length = 100

[isort]
profile=black
src_paths=wqio
# sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY"]
# # profile = "black"
# skip_gitignore = true
# force_to_top = ["true"]
# default_section = "THIRDPARTY"
# known_firstparty = ["wqio"]
18 changes: 9 additions & 9 deletions wqio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from . import bootstrap
from .ros import ROS, cohn_numbers
from .datasets import download
from .features import Location, Dataset
from .datacollections import DataCollection
from .samples import CompositeSample, GrabSample, Parameter
from .hydro import parse_storm_events, HydroRecord, Storm, DrainageArea
from . import utils
from .tests import test, teststrict
from wqio import bootstrap # noqa
from wqio import utils # noqa
from wqio.datacollections import DataCollection # noqa
from wqio.datasets import download # noqa
from wqio.features import Dataset, Location # noqa
from wqio.hydro import DrainageArea, HydroRecord, Storm, parse_storm_events # noqa
from wqio.ros import ROS, cohn_numbers # noqa
from wqio.samples import CompositeSample, GrabSample, Parameter # noqa
from wqio.tests import test, teststrict # noqa
7 changes: 3 additions & 4 deletions wqio/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from wqio import utils


_logger = logging.getLogger(__name__)

fitestimate = namedtuple(
Expand All @@ -18,7 +17,7 @@


def _acceleration(data):
""" Compute the acceleration statistic.
"""Compute the acceleration statistic.
Parameters
----------
Expand All @@ -39,11 +38,11 @@ def _acceleration(data):
sumsqr_resids = max(((data.mean() - data) ** 2).sum(), 1e-12)

# compute and return the acceleration
return sumcube_resids / (6 * sumsqr_resids ** 1.5)
return sumcube_resids / (6 * sumsqr_resids**1.5)


def _make_boot_index(elements, niter):
""" Generate an array of bootstrap sample sets
"""Generate an array of bootstrap sample sets
Parameters
----------
Expand Down
Loading
Loading