From 20267f2715ca411e33a10c03b14e57afa4e8a473 Mon Sep 17 00:00:00 2001 From: Julius Unverfehrt Date: Fri, 12 Aug 2022 12:34:21 +0200 Subject: [PATCH] remove nested list for figure detection response --- cv_analysis/server/pipeline.py | 4 ++-- test/unit_tests/server_pipeline_test.py | 26 ++++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cv_analysis/server/pipeline.py b/cv_analysis/server/pipeline.py index 8409a35..b1e4cbb 100644 --- a/cv_analysis/server/pipeline.py +++ b/cv_analysis/server/pipeline.py @@ -1,6 +1,6 @@ from operator import truth -from funcy import lmap +from funcy import lmap, flatten from cv_analysis.figure_detection.figure_detection import detect_figures from cv_analysis.table_parsing import parse_tables @@ -32,7 +32,7 @@ def make_analysis_pipeline(analysis_fn, formatter, dpi): pages = convert_pages_to_images(pdf, index=index, dpi=dpi) results = map(parse_page, pages) - yield from filter(truth, results) + yield from flatten(filter(truth, results)) return analyse_pipeline diff --git a/test/unit_tests/server_pipeline_test.py b/test/unit_tests/server_pipeline_test.py index c51b761..d4380b9 100644 --- a/test/unit_tests/server_pipeline_test.py +++ b/test/unit_tests/server_pipeline_test.py @@ -35,20 +35,18 @@ def expected_formatted_analysis_result(operation): ] if operation == "figure": return [ - [ - { - "pageInfo": { - "pageNumber": 0, - "pageRotation": 0, - "pageWidth": 595.0, - "pageHeight": 842.0, - "deRotationMatrix": (1.0, -0.0, -0.0, 1.0, 0.0, 0.0), - "transformationMatrix": (1.0, 0.0, 0.0, -1.0, -0.0, 842.0), - }, - "boundingBox": {"x0": 0.0, "y0": 0.0, "x1": 15.12, "y1": 15.12, "width": 15.12, "height": 15.12}, - "alpha": False, - } - ] + { + "pageInfo": { + "pageNumber": 0, + "pageRotation": 0, + "pageWidth": 595.0, + "pageHeight": 842.0, + "deRotationMatrix": (1.0, -0.0, -0.0, 1.0, 0.0, 0.0), + "transformationMatrix": (1.0, 0.0, 0.0, -1.0, -0.0, 842.0), + }, + "boundingBox": {"x0": 0.0, "y0": 0.0, "x1": 15.12, "y1": 15.12, "width": 15.12, "height": 15.12}, + "alpha": False, + } ]