refactoring

This commit is contained in:
Matthias Bisping 2022-04-14 19:14:29 +02:00
parent babc2a6fc8
commit 41b33dad65
3 changed files with 16 additions and 23 deletions

View File

@ -2,7 +2,6 @@ import logging
import pytest
from image_prediction.info import Info
from image_prediction.utils import get_logger
pytest_plugins = [
@ -26,10 +25,3 @@ def mute_logger():
logger.setLevel(logging.CRITICAL + 1)
yield
logger.setLevel(level)
@pytest.fixture
def info_label_map():
return Info

View File

@ -8,7 +8,7 @@ from test.utils.metadata import get_base_position_metadata
@pytest.fixture
def metadata(images, info_label_map):
def metadata(images):
page_idx = 0
def current_page_idx():
@ -25,16 +25,16 @@ def metadata(images, info_label_map):
y1 = random.randint(0, page_height - height)
y2 = y1 + height
metadata = {
info_label_map.PAGE_WIDTH: page_width,
info_label_map.PAGE_HEIGHT: page_height,
info_label_map.PAGE_IDX: current_page_idx(),
info_label_map.WIDTH: width,
info_label_map.HEIGHT: height,
info_label_map.X1: x1,
info_label_map.X2: x2,
info_label_map.Y1: y1,
info_label_map.Y2: y2,
info_label_map.ALPHA: image.mode == "RGBA",
Info.PAGE_WIDTH: page_width,
Info.PAGE_HEIGHT: page_height,
Info.PAGE_IDX: current_page_idx(),
Info.WIDTH: width,
Info.HEIGHT: height,
Info.X1: x1,
Info.X2: x2,
Info.Y1: y1,
Info.Y2: y2,
Info.ALPHA: image.mode == "RGBA",
}
return metadata
@ -53,4 +53,4 @@ def metadata_formatted(metadata):
def base_patch_metadata(width, height, page_width, page_height):
metadata = get_base_position_metadata(width, height, page_width, page_height)
metadata = merge(metadata, {Info.X1: 0, Info.Y1: 0, Info.X2: width, Info.Y2: height})
return metadata
return metadata

View File

@ -4,6 +4,7 @@ from image_prediction.compositor.compositor import TransformerCompositor
from image_prediction.formatter.formatters.camel_case import Snake2CamelCaseKeyFormatter
from image_prediction.formatter.formatters.enum import EnumFormatter
from image_prediction.formatter.formatters.identity import IdentityFormatter
from image_prediction.info import Info
from test.utils.comparison import transform_equal
@ -18,12 +19,12 @@ def test_composition(metadata, metadata_formatted):
@pytest.fixture()
def compositor_test_enum_metadata(info_label_map):
return [{info_label_map.WIDTH: 100, info_label_map.PAGE_WIDTH: 200}]
def compositor_test_enum_metadata():
return [{Info.WIDTH: 100, Info.PAGE_WIDTH: 200}]
@pytest.fixture()
def compositor_test_camel_case_metadata(info_label_map):
def compositor_test_camel_case_metadata():
return [{"width": 100, "pageWidth": 200}]