From 57315691eb32b731d8e5f37eedf04f7a6e683a32 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Jan 2023 11:41:13 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- histolab/stain_normalizer.py | 4 +++- tests/unit/test_stain_normalizer.py | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/histolab/stain_normalizer.py b/histolab/stain_normalizer.py index 329ab0a78..85300047d 100644 --- a/histolab/stain_normalizer.py +++ b/histolab/stain_normalizer.py @@ -379,7 +379,9 @@ def transform(self, img_rgb: PIL.Image.Image) -> PIL.Image.Image: norm_rgb = LabToRgb()(norm_lab) return norm_rgb - def _summary_statistics(self, img_rgb: PIL.Image.Image) -> Tuple[np.ndarray, np.ndarray]: + def _summary_statistics( + self, img_rgb: PIL.Image.Image + ) -> Tuple[np.ndarray, np.ndarray]: """Return mean and standard deviation of each channel in LAB color space. Parameters diff --git a/tests/unit/test_stain_normalizer.py b/tests/unit/test_stain_normalizer.py index b0a9403aa..ae9a3c9ce 100644 --- a/tests/unit/test_stain_normalizer.py +++ b/tests/unit/test_stain_normalizer.py @@ -373,7 +373,10 @@ def it_knows_how_to_calculate_summary_statistics(self, request): rgb_to_lab_.return_value = np.array(PILIMG.RGB_RANDOM_COLOR_500X500) reinhard_stain_normalizer = ReinhardStainNormalizer() - mean_per_channel, std_per_channel = reinhard_stain_normalizer._summary_statistics(img) + ( + mean_per_channel, + std_per_channel, + ) = reinhard_stain_normalizer._summary_statistics(img) assert isinstance(mean_per_channel, np.ndarray) assert isinstance(std_per_channel, np.ndarray) @@ -388,8 +391,13 @@ def it_knows_how_to_calculate_summary_statistics(self, request): def it_knows_how_to_fit(self, request): img = PILIMG.RGB_RANDOM_COLOR_500X500 - _summary_statistics_ = method_mock(request, ReinhardStainNormalizer, "_summary_statistics") - _summary_statistics_.return_value = (np.array([1.0, 1.0, 1.0]), np.array([2.0, 2.0, 2.0])) + _summary_statistics_ = method_mock( + request, ReinhardStainNormalizer, "_summary_statistics" + ) + _summary_statistics_.return_value = ( + np.array([1.0, 1.0, 1.0]), + np.array([2.0, 2.0, 2.0]), + ) reinhard_stain_normalizer = ReinhardStainNormalizer() reinhard_stain_normalizer.fit(img) @@ -404,8 +412,13 @@ def it_knows_how_to_fit(self, request): def it_knows_how_to_transform(self, request): img = PILIMG.RGB_RANDOM_COLOR_500X500 - _summary_statistics_ = method_mock(request, ReinhardStainNormalizer, "_summary_statistics") - _summary_statistics_.return_value = (np.array([1.0, 1.0, 1.0]), np.array([2.0, 2.0, 2.0])) + _summary_statistics_ = method_mock( + request, ReinhardStainNormalizer, "_summary_statistics" + ) + _summary_statistics_.return_value = ( + np.array([1.0, 1.0, 1.0]), + np.array([2.0, 2.0, 2.0]), + ) rgb_to_lab_ = method_mock(request, RgbToLab, "__call__") rgb_to_lab_.return_value = np.array(PILIMG.RGB_RANDOM_COLOR_500X500) tissue_mask_ = method_mock(request, ReinhardStainNormalizer, "_tissue_mask")