Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 14, 2023
1 parent de83fe3 commit 5731569
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion histolab/stain_normalizer.py
Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions tests/unit/test_stain_normalizer.py
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit 5731569

Please sign in to comment.