From ef70e1135218c3442e8c9157e7007f26abd60714 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Tue, 5 Apr 2022 19:38:29 +0200 Subject: [PATCH] refactoring --- test/utils/stitching.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/utils/stitching.py b/test/utils/stitching.py index 70a7076..bb4aca9 100644 --- a/test/utils/stitching.py +++ b/test/utils/stitching.py @@ -58,7 +58,7 @@ class BoxSplitter: new_boxes = splitter(box) return new_boxes - def __tree_recurse(self, boxes, step) + def __tree_recurse(self, boxes, step): return map(rpartial(self.__split_recursively, step + 1), boxes) def __split_horizontal(self, box): @@ -67,23 +67,27 @@ class BoxSplitter: def __split_vertical(self, box): return self.__split_if_large_enough(VerticalKeyMapper(box)) - def __split_if_large_enough(self, sabox: SplitKeyMapper): - return self.__get_child_boxes(sabox) if self.__large_enough(sabox) else self.__base_case(sabox.box) + def __split_if_large_enough(self, wrapped_box: SplitKeyMapper): + return ( + self.__get_child_boxes(wrapped_box) + if self.__large_enough(wrapped_box) + else self.__base_case(wrapped_box.box) + ) @staticmethod def __large_enough(box): return box["dim"] >= 10 @staticmethod - def __get_child_boxes(sabox: SplitKeyMapper): + def __get_child_boxes(wrapped_box: SplitKeyMapper): - split_len = random.randint(5, sabox["dim"] - 5) - split_point = sabox["c1"] + split_len + split_len = random.randint(5, wrapped_box["dim"] - 5) + split_point = wrapped_box["c1"] + split_len - box_left, box_right = juxt(deepcopy, deepcopy)(sabox) + box_left, box_right = juxt(deepcopy, deepcopy)(wrapped_box) box_left["dim"] = split_len - box_right["dim"] = sabox["dim"] - split_len + box_right["dim"] = wrapped_box["dim"] - split_len box_left["c2"] = split_point box_right["c1"] = split_point