Skip to content

Commit

Permalink
Merge 90e8ba3 into 60f2f7b
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoarbitrio committed Sep 30, 2020
2 parents 60f2f7b + 90e8ba3 commit 70fd293
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/benchmarks/test_benchmarks.py
@@ -1,10 +1,16 @@
# encoding: utf-8

import pytest

import numpy as np
from histolab.filters.util import mask_difference, mask_percent
from histolab.util import np_to_pil, apply_mask_image

from ..fixtures import NPY
from ..unitutil import PILIMG, NpArrayMock


class TestDescribeBenchmarksFilterUnit:
class TestDescribeBenchmarksFilterUtil:
def test_mask_difference(self, benchmark):
minuend = np.random.choice(a=[False, True], size=(5000, 4000))
subtrahend = np.random.choice(a=[False, True], size=(5000, 4000))
Expand All @@ -13,3 +19,18 @@ def test_mask_difference(self, benchmark):
def test_mask_percent(self, benchmark):
mask_array = np.random.choice(a=[False, True], size=(10000, 4000))
benchmark.pedantic(mask_percent, args=[mask_array], iterations=100, rounds=50)


class TestDescribeBenchmarksUtil:
def test_apply_mask_image(self, benchmark):
image = PILIMG.RGBA_COLOR_500X500_155_249_240
mask = NpArrayMock.ONES_500X500X4_BOOL
benchmark.pedantic(
apply_mask_image, args=[image, mask], iterations=100, rounds=50
)

@pytest.mark.parametrize(
"image", (NPY.NP_TO_PIL_RGBA, NPY.NP_TO_PIL_L, NPY.NP_TO_PIL_LA)
)
def test_np_to_pil(self, image, benchmark):
benchmark.pedantic(np_to_pil, args=[image], iterations=500, rounds=250)

0 comments on commit 70fd293

Please sign in to comment.