Ejemplo n.º 1
0
def test_basic(pair: BoundPortedRingManagersPair,
               operation_kinds_pair: BoundPortedOperationKindsPair,
               subject_fill_kinds_pair: BoundPortedFillKindsPair,
               clip_fill_kinds_pair: BoundPortedFillKindsPair,
               local_minimum_lists_pair_index_top_y: Tuple[
                   BoundPortedLocalMinimumListsPair, int, Coordinate],
               active_bounds_pair: BoundPortedBoundsListsPair) -> None:
    bound, ported = pair
    bound_operation_kind, ported_operation_kind = operation_kinds_pair
    bound_subject_fill_kind, ported_subject_fill_kind = subject_fill_kinds_pair
    bound_clip_fill_kind, ported_clip_fill_kind = clip_fill_kinds_pair
    ((bound_local_minimum_list, ported_local_minimum_list), index,
     bottom_y) = local_minimum_lists_pair_index_top_y
    bound_active_bounds, ported_active_bounds = active_bounds_pair
    bound_scanbeams = bound_local_minimum_list.scanbeams
    ported_scanbeams = ported_local_minimum_list.scanbeams

    (bound_active_bounds, bound_scanbeams,
     bound_result) = bound.insert_local_minima_into_abl(
         bound_operation_kind, bound_subject_fill_kind, bound_clip_fill_kind,
         bottom_y, bound_scanbeams, bound_local_minimum_list, index,
         bound_active_bounds)
    ported_result = ported.insert_local_minima_into_abl(
        ported_operation_kind, ported_subject_fill_kind, ported_clip_fill_kind,
        bottom_y, ported_scanbeams, ported_local_minimum_list, index,
        ported_active_bounds)

    assert bound_result == ported_result
    assert bound_scanbeams == ported_scanbeams
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 2
0
def test_basic(pair: BoundPortedRingManagersPair) -> None:
    bound, ported = pair

    bound.correct_chained_rings()
    ported.correct_chained_rings()

    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 3
0
def test_basic(pair: BoundPortedRingManagersPair,
               operation_kinds_pair: BoundPortedOperationKindsPair,
               subject_fill_kinds_pair: BoundPortedFillKindsPair,
               clip_fill_kinds_pair: BoundPortedFillKindsPair,
               active_bounds_pair_scanbeams_scanline_y_index
               : Tuple[BoundPortedBoundsListsPair, List[Coordinate],
                       Coordinate, int]) -> None:
    bound, ported = pair
    bound_operation_kind, ported_operation_kind = operation_kinds_pair
    bound_subject_fill_kind, ported_subject_fill_kind = subject_fill_kinds_pair
    bound_clip_fill_kind, ported_clip_fill_kind = clip_fill_kinds_pair
    ((bound_active_bounds, ported_active_bounds), scanbeams, scanline_y,
     index) = active_bounds_pair_scanbeams_scanline_y_index
    bound_scanbeams, ported_scanbeams = scanbeams, scanbeams[:]

    (bound_active_bounds, bound_scanbeams,
     bound_result) = bound.process_horizontal(
            bound_operation_kind, bound_subject_fill_kind,
            bound_clip_fill_kind, scanline_y, bound_scanbeams, index,
            bound_active_bounds)
    ported_result = ported.process_horizontal(
            ported_operation_kind, ported_subject_fill_kind,
            ported_clip_fill_kind, scanline_y, ported_scanbeams, index,
            ported_active_bounds)

    assert bound_result == ported_result
    assert bound_scanbeams == ported_scanbeams
    assert are_bound_ported_maybe_bounds_lists_equal(bound_active_bounds,
                                                     ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 4
0
def test_basic(
    pair: BoundPortedRingManagersPair, points_pair: BoundPortedPointsPair,
    operation_kinds_pair: BoundPortedOperationKindsPair,
    subject_fill_kinds_pair: BoundPortedFillKindsPair,
    clip_fill_kinds_pair: BoundPortedFillKindsPair,
    active_bounds_pair_indices_pair: Tuple[BoundPortedBoundsListsPair,
                                           Tuple[int, int]]
) -> None:
    bound, ported = pair
    bound_point, ported_point = points_pair
    bound_operation_kind, ported_operation_kind = operation_kinds_pair
    bound_subject_fill_kind, ported_subject_fill_kind = subject_fill_kinds_pair
    bound_clip_fill_kind, ported_clip_fill_kind = clip_fill_kinds_pair
    ((bound_active_bounds, ported_active_bounds),
     (first_index, second_index)) = active_bounds_pair_indices_pair
    ported_first_bound = ported_active_bounds[first_index]
    ported_second_bound = ported_active_bounds[second_index]

    bound_active_bounds = bound.intersect_bounds(
        bound_point, bound_operation_kind, bound_subject_fill_kind,
        bound_clip_fill_kind, first_index, second_index, bound_active_bounds)
    ported.intersect_bounds(ported_point, ported_operation_kind,
                            ported_subject_fill_kind, ported_clip_fill_kind,
                            ported_first_bound, ported_second_bound,
                            ported_active_bounds)

    assert are_bound_ported_bounds_equal(bound_active_bounds[first_index],
                                         ported_first_bound)
    assert are_bound_ported_bounds_equal(bound_active_bounds[second_index],
                                         ported_second_bound)
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 5
0
def test_basic(pair: BoundPortedRingManagersPair,
               local_minimum_lists_pair_index_top_y
               : Tuple[BoundPortedLocalMinimumListsPair, int, Coordinate],
               active_bounds_pair: BoundPortedBoundsListsPair
               ) -> None:
    bound, ported = pair
    ((bound_local_minimum_list, ported_local_minimum_list), index,
     top_y) = local_minimum_lists_pair_index_top_y
    bound_active_bounds, ported_active_bounds = active_bounds_pair
    bound_scanbeams = bound_local_minimum_list.scanbeams
    ported_scanbeams = ported_local_minimum_list.scanbeams

    (bound_active_bounds, bound_scanbeams,
     bound_result) = bound.insert_local_minima_into_abl_hot_pixel(
            top_y, bound_local_minimum_list, index, bound_active_bounds,
            bound_scanbeams)
    ported_result = ported.insert_local_minima_into_abl_hot_pixel(
            top_y, ported_local_minimum_list, index, ported_active_bounds,
            ported_scanbeams)

    assert bound_result == ported_result
    assert bound_scanbeams == ported_scanbeams
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 6
0
def test_basic(pair: BoundPortedRingManagersPair) -> None:
    bound, ported = pair

    bound.sort_hot_pixels()
    ported.sort_hot_pixels()

    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 7
0
def test_basic(pair: BoundPortedRingManagersPair) -> None:
    bound, ported = pair

    bound_result = bound.create_ring()
    ported_result = ported.create_ring()

    assert are_bound_ported_rings_equal(bound_result, ported_result)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 8
0
def test_basic(pair: BoundPortedRingManagersPair, correct_tree: bool) -> None:
    bound, ported = pair

    bound_result = bound.correct_self_intersections(correct_tree)
    ported_result = ported.correct_self_intersections(correct_tree)

    assert equivalence(bound_result, ported_result)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 9
0
def test_basic(
        pair: BoundPortedRingManagersPair,
        local_minimum_lists_pair: BoundPortedLocalMinimumListsPair) -> None:
    bound, ported = pair
    (bound_local_minimum_list,
     ported_local_minimum_list) = local_minimum_lists_pair

    bound.build_hot_pixels(bound_local_minimum_list)
    ported.build_hot_pixels(ported_local_minimum_list)

    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 10
0
def test_basic(pair: BoundPortedRingManagersPair) -> None:
    bound, ported = pair

    try:
        bound.correct_topology()
    except RuntimeError:
        with pytest.raises(RuntimeError):
            ported.correct_topology()
    else:
        ported.correct_topology()

        assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 11
0
def test_basic(pair: BoundPortedRingManagersPair,
               bounds_pair: BoundPortedBoundsPair,
               points_pair: BoundPortedPointsPair) -> None:
    bound, ported = pair
    bound_bound, ported_bound = bounds_pair
    bound_point, ported_point = points_pair

    ported.add_point_to_ring(ported_bound, ported_point)
    bound.add_point_to_ring(bound_bound, bound_point)

    assert are_bound_ported_bounds_equal(bound_bound, ported_bound)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 12
0
def test_basic(pair: BoundPortedRingManagersPair,
               bounds_pair: BoundPortedBoundsPair,
               end_points_pair: BoundPortedPointsPair,
               add_end_point: bool) -> None:
    bound, ported = pair
    bound_bound, ported_bound = bounds_pair
    bound_end_point, ported_end_point = end_points_pair

    bound.insert_hot_pixels_in_path(bound_bound, bound_end_point,
                                    add_end_point)
    ported.insert_hot_pixels_in_path(ported_bound, ported_end_point,
                                     add_end_point)

    assert are_bound_ported_bounds_equal(bound_bound, ported_bound)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 13
0
def test_basic(pair: BoundPortedRingManagersPair,
               active_bounds_pair_index: Tuple[BoundPortedBoundsListsPair, int]
               ) -> None:
    bound, ported = pair
    ((bound_active_bounds, ported_active_bounds),
     index) = active_bounds_pair_index
    ported_bound = ported_active_bounds[index]

    bound_active_bounds = bound.set_hole_state(index, bound_active_bounds)
    ported.set_hole_state(ported_bound, ported_active_bounds)

    assert are_bound_ported_bounds_equal(bound_active_bounds[index],
                                         ported_bound)
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 14
0
def test_basic(pair: BoundPortedRingManagersPair, top_y: Coordinate,
               active_bounds_pair: BoundPortedBoundsListsPair) -> None:
    bound, ported = pair
    bound_active_bounds, ported_active_bounds = active_bounds_pair

    try:
        bound_result = bound.process_hot_pixel_intersections(
            top_y, bound_active_bounds)
    except RuntimeError:
        with pytest.raises(RuntimeError):
            ported.process_hot_pixel_intersections(top_y, ported_active_bounds)
    else:
        ported_result = ported.process_hot_pixel_intersections(
            top_y, ported_active_bounds)

        assert are_bound_ported_bounds_lists_equal(bound_result, ported_result)
        assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 15
0
def test_basic(pair: BoundPortedRingManagersPair,
               active_bounds_pair_index: Tuple[BoundPortedBoundsListsPair,
                                               int],
               points_pair: BoundPortedPointsPair) -> None:
    bound, ported = pair
    ((bound_active_bounds, ported_active_bounds),
     index) = active_bounds_pair_index
    bound_point, ported_point = points_pair
    ported_bound = ported_active_bounds[index]

    bound_active_bounds = bound.add_point(index, bound_active_bounds,
                                          bound_point)
    ported.add_point(ported_bound, ported_active_bounds, ported_point)

    assert are_bound_ported_bounds_equal(bound_active_bounds[index],
                                         ported_bound)
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 16
0
def test_basic(pair: BoundPortedRingManagersPair,
               top_y: Coordinate,
               active_bounds_pair_index: Tuple[BoundPortedBoundsListsPair, int]
               ) -> None:
    bound, ported = pair
    (bound_active_bounds,
     ported_active_bounds), index = active_bounds_pair_index

    (bound_active_bounds, bound_index,
     bound_result) = bound.horizontals_at_top_scanbeam(
            top_y, bound_active_bounds, index)
    ported_index, ported_result = ported.horizontals_at_top_scanbeam(
            top_y, ported_active_bounds, index)

    assert equivalence(bound_result, ported_result)
    assert bound_index == ported_index
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 17
0
def test_basic(pair_start_stop: Tuple[BoundPortedRingManagersPair,
                                      Tuple[int, int]], y: Coordinate,
               start_x_end_x: Tuple[Coordinate, Coordinate],
               bounds_pair: BoundPortedBoundsPair,
               add_end_point: bool) -> None:
    (bound, ported), (start, stop) = pair_start_stop
    start_x, end_x = start_x_end_x
    bound_bound, ported_bound = bounds_pair

    bound_result = bound.hot_pixel_set_left_to_right(y, start_x, end_x,
                                                     bound_bound, start, stop,
                                                     add_end_point)
    ported_result = ported.hot_pixel_set_left_to_right(y, start_x, end_x,
                                                       ported_bound, start,
                                                       stop, add_end_point)

    assert bound_result == ported_result
    assert are_bound_ported_bounds_equal(bound_bound, ported_bound)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 18
0
def test_basic(pair: BoundPortedRingManagersPair,
               active_bounds_pair_indices_pair
               : Tuple[BoundPortedBoundsListsPair, Tuple[int, int]]) -> None:
    bound, ported = pair
    ((bound_active_bounds, ported_active_bounds),
     (first_index, second_index)) = active_bounds_pair_indices_pair
    ported_first_bound = ported_active_bounds[first_index]
    ported_second_bound = ported_active_bounds[second_index]

    bound_active_bounds = bound.append_ring(first_index, second_index,
                                            bound_active_bounds)
    ported.append_ring(ported_first_bound, ported_second_bound,
                       ported_active_bounds)

    assert are_bound_ported_bounds_equal(bound_active_bounds[first_index],
                                         ported_first_bound)
    assert are_bound_ported_bounds_equal(bound_active_bounds[second_index],
                                         ported_second_bound)
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 19
0
def test_basic(
    pair: BoundPortedRingManagersPair,
    active_bounds_pair_scanbeams_top_y: Tuple[BoundPortedBoundsListsPair,
                                              List[Coordinate], Coordinate]
) -> None:
    bound, ported = pair
    ((bound_active_bounds, ported_active_bounds), scanbeams,
     top_y) = active_bounds_pair_scanbeams_top_y
    bound_scanbeams, ported_scanbeams = scanbeams, scanbeams[:]

    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)

    bound_result, bound_scanbeams = (
        bound.process_hot_pixel_edges_at_top_of_scanbeam(
            top_y, bound_scanbeams, bound_active_bounds))
    ported_result = ported.process_hot_pixel_edges_at_top_of_scanbeam(
        top_y, ported_scanbeams, ported_active_bounds)

    assert bound_scanbeams == ported_scanbeams
    assert are_bound_ported_bounds_lists_equal(bound_result, ported_result)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 20
0
def test_basic(
    pair: BoundPortedRingManagersPair,
    operation_kinds_pair: BoundPortedOperationKindsPair,
    subject_fill_kinds_pair: BoundPortedFillKindsPair,
    clip_fill_kinds_pair: BoundPortedFillKindsPair,
    scanbeams: List[Coordinate],
    active_bounds_pair_indices_pair: Tuple[BoundPortedBoundsListsPair,
                                           Tuple[int, int]]
) -> None:
    bound, ported = pair
    bound_operation_kind, ported_operation_kind = operation_kinds_pair
    bound_subject_fill_kind, ported_subject_fill_kind = subject_fill_kinds_pair
    bound_clip_fill_kind, ported_clip_fill_kind = clip_fill_kinds_pair
    bound_scanbeams, ported_scanbeams = scanbeams, scanbeams[:]
    ((bound_active_bounds, ported_active_bounds),
     (first_index, second_index)) = active_bounds_pair_indices_pair
    ported_first_bound = ported_active_bounds[first_index]
    ported_second_bound = ported_active_bounds[second_index]

    bound_scanbeams, bound_active_bounds = (
        bound.insert_lm_left_and_right_bound(bound_operation_kind,
                                             bound_subject_fill_kind,
                                             bound_clip_fill_kind,
                                             bound_scanbeams, first_index,
                                             second_index,
                                             bound_active_bounds))
    ported.insert_lm_left_and_right_bound(ported_operation_kind,
                                          ported_subject_fill_kind,
                                          ported_clip_fill_kind,
                                          ported_scanbeams, ported_first_bound,
                                          ported_second_bound,
                                          ported_active_bounds)

    assert bound_scanbeams == ported_scanbeams
    assert are_bound_ported_bounds_lists_equal(bound_active_bounds,
                                               ported_active_bounds)
    assert are_bound_ported_ring_managers_equal(bound, ported)
Ejemplo n.º 21
0
def test_basic(
    pair: BoundPortedRingManagersPair,
    operation_kinds_pair: BoundPortedOperationKindsPair,
    subject_fill_kinds_pair: BoundPortedFillKindsPair,
    clip_fill_kinds_pair: BoundPortedFillKindsPair,
    active_bounds_pair_indices_pair: Tuple[BoundPortedBoundsListsPair,
                                           Tuple[int, int]]
) -> None:
    bound, ported = pair
    bound_operation_kind, ported_operation_kind = operation_kinds_pair
    bound_subject_fill_kind, ported_subject_fill_kind = subject_fill_kinds_pair
    bound_clip_fill_kind, ported_clip_fill_kind = clip_fill_kinds_pair
    ((bound_active_bounds, ported_active_bounds),
     (bound_index, bound_maximum_index)) = active_bounds_pair_indices_pair

    try:
        bound_active_bounds, bound_result = bound.do_maxima(
            bound_operation_kind, bound_subject_fill_kind,
            bound_clip_fill_kind, bound_index, bound_maximum_index,
            bound_active_bounds)
    except RuntimeError:
        with pytest.raises(RuntimeError):
            ported.do_maxima(ported_operation_kind, ported_subject_fill_kind,
                             ported_clip_fill_kind, bound_index,
                             bound_maximum_index, ported_active_bounds)
    else:
        ported_result = ported.do_maxima(ported_operation_kind,
                                         ported_subject_fill_kind,
                                         ported_clip_fill_kind, bound_index,
                                         bound_maximum_index,
                                         ported_active_bounds)

        assert bound_result == ported_result
        assert are_bound_ported_maybe_bounds_lists_equal(
            bound_active_bounds, ported_active_bounds)
        assert are_bound_ported_ring_managers_equal(bound, ported)