diff --git a/test/unit_tests/figure_detection/figure_detection_test.py b/test/unit_tests/figure_detection/figure_detection_test.py index ce6c3dc..93c36ed 100644 --- a/test/unit_tests/figure_detection/figure_detection_test.py +++ b/test/unit_tests/figure_detection/figure_detection_test.py @@ -3,6 +3,7 @@ from math import prod import cv2 import pytest +from cv_analysis.utils.spacial import area from test.utils.utils import powerset @@ -26,7 +27,7 @@ class TestFindPrimaryTextRegions: @pytest.mark.parametrize("error_tolerance", [0.025]) def test_page_with_only_text_yields_no_figures(self, figure_detection_pipeline, page_with_text, error_tolerance): result_rectangles = figure_detection_pipeline(page_with_text) - result_figure_areas = sum(map(lambda r: (r.width * r.height), result_rectangles)) + result_figure_areas = sum(map(area, result_rectangles)) page_area = prod(page_with_text.shape) error = result_figure_areas / page_area @@ -46,7 +47,7 @@ class TestFindPrimaryTextRegions: ): result_rectangles = list(figure_detection_pipeline(page_with_images_and_text)) - result_figure_areas = sum(map(lambda r: (r.width * r.height), result_rectangles)) + result_figure_areas = sum(map(area, result_rectangles)) expected_figure_area = prod(image_size) error = abs(result_figure_areas - expected_figure_area) / expected_figure_area