diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1eb102d..808d664 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ exclude: 'docs|node_modules|migrations|.git|.tox' -default_stages: [commit] +default_stages: [pre-commit] fail_fast: true repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: trailing-whitespace files: (^|/)a/.+\.(py|html|sh|css|js)$ @@ -12,12 +12,12 @@ repos: args: ["--maxkb=2000"] # Linting with ruff -- repo: https://github.com/charliermarsh/ruff-pre-commit +- repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.1.6' + rev: 'v0.15.18' hooks: - - id: ruff + - id: ruff-check types_or: [ python, pyi, jupyter ] - args: [--fix, --exit-non-zero-on-fix] + args: [--fix] - id: ruff-format types_or: [ python, pyi, jupyter ] diff --git a/src/gregor/disaggregate.py b/src/gregor/disaggregate.py index 95dbc1e..b08cc4f 100644 --- a/src/gregor/disaggregate.py +++ b/src/gregor/disaggregate.py @@ -228,9 +228,9 @@ def disaggregate_polygon_to_point( ) # Make sure that it belongs to only one polygon - assert ( - points.belongs_to.apply(len).max() == 1 - ), "Every Point should belong to exactly one polygon." + assert points.belongs_to.apply(len).max() == 1, ( + "Every Point should belong to exactly one polygon." + ) points.belongs_to = points.belongs_to.apply(lambda x: x[0]) # Warn if there are polygons without points. diff --git a/test/test_aggregate.py b/test/test_aggregate.py index afe6b55..ad14e28 100644 --- a/test/test_aggregate.py +++ b/test/test_aggregate.py @@ -1,7 +1,8 @@ import pytest -from gregor.aggregate import aggregate_point_to_polygon, aggregate_raster_to_polygon from numpy.testing import assert_array_equal +from gregor.aggregate import aggregate_point_to_polygon, aggregate_raster_to_polygon + def test_agg_tif_2x2(square_segmentation_2x2): agg_raster_poly = aggregate_raster_to_polygon( diff --git a/test/test_belongs_to.py b/test/test_belongs_to.py index f333c0a..0232d6b 100644 --- a/test/test_belongs_to.py +++ b/test/test_belongs_to.py @@ -1,6 +1,7 @@ -from gregor.disaggregate import get_belongs_to_matrix from numpy.testing import assert_array_equal +from gregor.disaggregate import get_belongs_to_matrix + def test_belongs_to_matrix_square_segmentation_2x2( dummy_raster, square_segmentation_2x2 diff --git a/test/test_disaggregate.py b/test/test_disaggregate.py index 39d2c97..b09d20f 100644 --- a/test/test_disaggregate.py +++ b/test/test_disaggregate.py @@ -1,4 +1,5 @@ import numpy as np + from gregor.disaggregate import ( disaggregate_polygon_to_point, disaggregate_polygon_to_raster, diff --git a/test/test_performance.py b/test/test_performance.py index 174222b..504826c 100644 --- a/test/test_performance.py +++ b/test/test_performance.py @@ -1,8 +1,9 @@ import numpy as np import pytest -from gregor.disaggregate import disaggregate_polygon_to_raster from memory_log import MemoryLogger +from gregor.disaggregate import disaggregate_polygon_to_raster + @pytest.mark.benchmark def test_performance_disaggregate_to_raster(large_raster, large_polygons):