refactoring
This commit is contained in:
parent
50b4d239cb
commit
803cc57155
@ -8,11 +8,12 @@ import fpdf
|
||||
import numpy as np
|
||||
import pytest
|
||||
from PIL import Image
|
||||
from funcy import merge, second, compose, rpartial, juxt, rest, first, one
|
||||
from funcy import merge, second, compose, rpartial, juxt, rest, first, one, iterate
|
||||
|
||||
from image_prediction.estimator.preprocessor.utils import image_to_normalized_tensor
|
||||
from image_prediction.image_extractor.extractor import ImageMetadataPair
|
||||
from image_prediction.info import Info
|
||||
from image_prediction.utils import chunk_iterable
|
||||
from test.conftest import (
|
||||
get_base_position_metadata,
|
||||
add_image,
|
||||
@ -147,15 +148,13 @@ def merge_group(group, direction):
|
||||
c2_getter = make_coord_getter(f"{direction}2")
|
||||
pair_merger = make_pair_merger(direction)
|
||||
|
||||
pairs = list(group)
|
||||
def reduce_group(group):
|
||||
group_reduced = merge_with(*juxt(first, rest)(group))
|
||||
return group_reduced
|
||||
|
||||
while True:
|
||||
new_pairs = merge_with(*juxt(first, rest)(pairs))
|
||||
if len(new_pairs) == len(pairs):
|
||||
break
|
||||
pairs = new_pairs
|
||||
|
||||
return new_pairs
|
||||
for g1, g2 in chunk_iterable(iterate(reduce_group, group), chunk_size=2):
|
||||
if len(g1) == len(g2):
|
||||
return g1
|
||||
|
||||
|
||||
def merge_group_horizontally(group):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user