From bc3b8e8dd1bb7fa7f7e4209e2fe99a29a7d218eb Mon Sep 17 00:00:00 2001 From: Donnie Erb <55961724+derb12@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:34:50 -0500 Subject: [PATCH] MAINT: Fix linting errors Also updated ruffs rules. --- .github/workflows/python-test.yml | 2 +- pybaselines/classification.py | 1 - pyproject.toml | 1 + requirements/requirements-development.txt | 2 +- tests/test_algorithm_setup.py | 1 - tests/test_banded_utils.py | 2 -- tests/test_meta.py | 1 - tests/test_utils.py | 1 + tests/test_validation.py | 2 ++ tests/two_d/test_spline.py | 1 - 10 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 6c1006a..bba42bb 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -110,4 +110,4 @@ jobs: run: python -m pip install ruff - name: Lint - run: ruff check . --show-source + run: ruff check . diff --git a/pybaselines/classification.py b/pybaselines/classification.py index 0e12312..e23b665 100644 --- a/pybaselines/classification.py +++ b/pybaselines/classification.py @@ -805,7 +805,6 @@ def fabc(self, data, lam=1e6, scale=None, num_std=3.0, diff_order=2, min_length= return baseline, params - @_Algorithm._register(sort_keys=('mask',)) def rubberband(self, data, segments=1, lam=None, diff_order=2, weights=None, smooth_half_window=None, **pad_kwargs): diff --git a/pyproject.toml b/pyproject.toml index e8fce4c..16e5133 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,6 +98,7 @@ known_local_folder = ["example_helpers"] exclude = ["docs/*"] line-length = 100 fix = false +output-format = "full" [tool.ruff.lint] preview = true # for using experimental rules diff --git a/requirements/requirements-development.txt b/requirements/requirements-development.txt index 14aab52..3cbc419 100644 --- a/requirements/requirements-development.txt +++ b/requirements/requirements-development.txt @@ -2,7 +2,7 @@ -r requirements-documentation.txt # for linting -ruff==0.2.1 +ruff==0.2.2 # for testing pytest==8.0.0 diff --git a/tests/test_algorithm_setup.py b/tests/test_algorithm_setup.py index f5738e3..14cdb23 100644 --- a/tests/test_algorithm_setup.py +++ b/tests/test_algorithm_setup.py @@ -626,7 +626,6 @@ def func2(self, data, *args, **kwargs): } return 1 * data, params - if change_order: x[sort_indices] = x[sort_indices][::-1] y[sort_indices] = y[sort_indices][::-1] diff --git a/tests/test_banded_utils.py b/tests/test_banded_utils.py index c71c3b3..d8069df 100644 --- a/tests/test_banded_utils.py +++ b/tests/test_banded_utils.py @@ -107,7 +107,6 @@ def test_diff_penalty_diagonals_datasize_too_small(): _banded_utils.diff_penalty_diagonals(-1) - @pytest.mark.parametrize('data_size', (10, 51)) @pytest.mark.parametrize('diff_order', (1, 2, 3, 4)) def test_diff_penalty_matrix(data_size, diff_order): @@ -452,7 +451,6 @@ def check_penalized_system(penalized_system, expected_penalty, lam, diff_order, ) - @pytest.mark.parametrize('diff_order', (1, 2, 3)) @pytest.mark.parametrize('allow_lower', (True, False)) @pytest.mark.parametrize('reverse_diags', (None, True, False)) diff --git a/tests/test_meta.py b/tests/test_meta.py index 7aa036a..0108a4e 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -409,7 +409,6 @@ def test_setup(self): assert self.param_keys == [] assert self.two_d - def test_reverse_array(self): """Ensures the reverse_array funcion works correctly.""" assert_allclose(self.reverse_array(self.y), self.y[..., ::-1]) diff --git a/tests/test_utils.py b/tests/test_utils.py index 5113c21..a39323a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -40,6 +40,7 @@ def test_gaussian(_x_data, height, center, sigma): gaussian(_x_data, height, center, sigma), 1e-12, 1e-12 ) + @pytest.mark.parametrize('sigma', (0, -1)) def test_gaussian_non_positive_sigma(_x_data, sigma): """Ensures a sigma value not greater than 0 raises an exception.""" diff --git a/tests/test_validation.py b/tests/test_validation.py index fd9caf1..6085484 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -38,6 +38,7 @@ def test_yx_arrays_no_x(small_data): assert isinstance(y, np.ndarray) assert_allclose(y, small_data, rtol=1e-12, atol=1e-12) + @pytest.mark.parametrize('array_enum', (0, 1)) def test_yxz_arrays_output_array(data_fixture2d, array_enum): """Ensures output y, x, and z are always numpy arrays and that x and z are not scaled.""" @@ -343,6 +344,7 @@ def test_check_half_window_failures(): with pytest.raises(TypeError): _validation._check_half_window(5.01) + @pytest.mark.parametrize( 'half_window', ( 5, 5.0, [5], (5,), [[5]], np.array(5), np.array([5]), np.array([[5]]), diff --git a/tests/two_d/test_spline.py b/tests/two_d/test_spline.py index e4d7660..e952bd3 100644 --- a/tests/two_d/test_spline.py +++ b/tests/two_d/test_spline.py @@ -189,7 +189,6 @@ def test_diff_order_one_fails(self): with pytest.raises(ValueError): self.class_func(self.y, diff_order=[2, 1]) - @pytest.mark.parametrize('lam', (1e1, 1e5, [1e1, 1e5])) @pytest.mark.parametrize('lam_1', (1e1, [1e1, 1e5])) @pytest.mark.parametrize('p', (0.01, 0.1))