From bb09dde80504ef0b4b29daac63371bb8c3dc30ba Mon Sep 17 00:00:00 2001 From: "S. Gay" Date: Fri, 15 Dec 2023 07:35:12 -0600 Subject: [PATCH] Specify black line length is 88 characters This is the default black setting, but some users (like me) will globally override to a different length. Better to explicitly specify. --- .pre-commit-config.yaml | 1 + doc/numpydoc/numpydoc/linkcode.py | 5 +- doc/source/conf.py | 4 +- tests/filter_/anisotropic_diffusion.py | 5 +- tests/filter_/houghtransform.py | 96 ++++---------------------- tests/graphcut_/energy_label.py | 24 +------ 6 files changed, 19 insertions(+), 116 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d9fc20..1b2b364 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,7 @@ repos: rev: 23.12.0 hooks: - id: black + args: ["--line-length=88"] - repo: https://github.com/hadialqattan/pycln rev: "v2.4.0" diff --git a/doc/numpydoc/numpydoc/linkcode.py b/doc/numpydoc/numpydoc/linkcode.py index 5704a7f..543e747 100644 --- a/doc/numpydoc/numpydoc/linkcode.py +++ b/doc/numpydoc/numpydoc/linkcode.py @@ -41,10 +41,7 @@ def doctree_read(app, doctree): raise LinkcodeError("Function `linkcode_resolve` is not given in conf.py") domain_keys = dict( - py=["module", "fullname"], - c=["names"], - cpp=["names"], - js=["object", "fullname"], + py=["module", "fullname"], c=["names"], cpp=["names"], js=["object", "fullname"] ) for objnode in doctree.traverse(addnodes.desc): diff --git a/doc/source/conf.py b/doc/source/conf.py index b36ae7c..9c633ac 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -223,7 +223,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ("index", "MedPy.tex", "MedPy Documentation", "Oskar Maier", "manual"), + ("index", "MedPy.tex", "MedPy Documentation", "Oskar Maier", "manual") ] # The name of an image file (relative to this directory) to place at the top of @@ -271,7 +271,7 @@ "MedPy", "One line description of project.", "Miscellaneous", - ), + ) ] # Documents to append as an appendix to all manuals. diff --git a/tests/filter_/anisotropic_diffusion.py b/tests/filter_/anisotropic_diffusion.py index 4b12301..5747272 100644 --- a/tests/filter_/anisotropic_diffusion.py +++ b/tests/filter_/anisotropic_diffusion.py @@ -40,8 +40,5 @@ def test_anisotropic_diffusion_voxel_spacing_array(): # Purpose of this test is to ensure the filter code does not crash # Depending on Python versions arr = np.random.uniform(size=(60, 31, 3)) - filtered = anisotropic_diffusion( - arr, - voxelspacing=np.array([1, 1, 1.0]), - ) + filtered = anisotropic_diffusion(arr, voxelspacing=np.array([1, 1, 1.0])) assert filtered.shape == arr.shape diff --git a/tests/filter_/houghtransform.py b/tests/filter_/houghtransform.py index e8e0d5a..5a56177 100644 --- a/tests/filter_/houghtransform.py +++ b/tests/filter_/houghtransform.py @@ -195,94 +195,22 @@ def test_template_ellipsoid(self): # prepare expected = [ [ - [ - False, - False, - False, - False, - False, - ], - [ - False, - True, - True, - True, - False, - ], - [ - False, - True, - True, - True, - False, - ], - [ - False, - False, - False, - False, - False, - ], + [False, False, False, False, False], + [False, True, True, True, False], + [False, True, True, True, False], + [False, False, False, False, False], ], [ - [ - False, - True, - True, - True, - False, - ], - [ - True, - True, - True, - True, - True, - ], - [ - True, - True, - True, - True, - True, - ], - [ - False, - True, - True, - True, - False, - ], + [False, True, True, True, False], + [True, True, True, True, True], + [True, True, True, True, True], + [False, True, True, True, False], ], [ - [ - False, - False, - False, - False, - False, - ], - [ - False, - True, - True, - True, - False, - ], - [ - False, - True, - True, - True, - False, - ], - [ - False, - False, - False, - False, - False, - ], + [False, False, False, False, False], + [False, True, True, True, False], + [False, True, True, True, False], + [False, False, False, False, False], ], ] diff --git a/tests/graphcut_/energy_label.py b/tests/graphcut_/energy_label.py index 379711b..431b7a9 100644 --- a/tests/graphcut_/energy_label.py +++ b/tests/graphcut_/energy_label.py @@ -42,17 +42,7 @@ class TestEnergyLabel(unittest.TestCase): # dedicated function tests def test_boundary_stawiaski(self): - label = [ - [[1, 1], [1, 1]], - [[1, 2], [2, 2]], - [ - [2, 2], - [ - 2, - 2, - ], - ], - ] + label = [[[1, 1], [1, 1]], [[1, 2], [2, 2]], [[2, 2], [2, 2]]] expected_result = {(0, 1): (6, 6)} self.__run_boundary_stawiaski_test( label, numpy.zeros_like(label), expected_result, "3D images" @@ -146,17 +136,7 @@ def test_exception_not_starting_with_index_one(self): assert_raises(AttributeError, bt, None, label, (None, None)) def test_boundary_difference_of_means_borders(self): - label = [ - [[1, 1], [1, 1]], - [[1, 2], [2, 2]], - [ - [2, 2], - [ - 2, - 2, - ], - ], - ] + label = [[[1, 1], [1, 1]], [[1, 2], [2, 2]], [[2, 2], [2, 2]]] expected_result = {(0, 1): (sys.float_info.min, sys.float_info.min)} self.__run_boundary_difference_of_means_test( label, numpy.zeros_like(label), expected_result, "3D images"