Exemple #1
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)
Exemple #2
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)
Exemple #3
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)
Exemple #4
0
def test_basic(lists_pair_index: Tuple[BoundPortedBoundsListsPair, int],
               subject_fill_kinds_pair: BoundPortedFillKindsPair,
               clip_fill_kinds_pair: BoundPortedFillKindsPair) -> None:
    (bound_list, ported_list), index = lists_pair_index
    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_list = bound(index, bound_list, bound_subject_fill_kind,
                       bound_clip_fill_kind)
    ported(index, ported_list, ported_subject_fill_kind, ported_clip_fill_kind)

    assert are_bound_ported_bounds_lists_equal(bound_list, ported_list)
Exemple #5
0
def test_basic(first_pair: BoundPortedBoundsPair,
               second_pair: BoundPortedBoundsPair,
               lists_pair: BoundPortedBoundsListsPair) -> None:
    first_bound, first_ported = first_pair
    second_bound, second_ported = second_pair
    bound_list, ported_list = lists_pair

    bound_list, bound_result = bound(first_bound, second_bound, bound_list)
    ported_result = ported(first_ported, second_ported, ported_list)

    assert bound_result == ported_result
    assert are_bound_ported_bounds_lists_equal(bound_list, ported_list)
Exemple #6
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)
Exemple #7
0
def test_basic(lists_pair: BoundPortedBoundsListsPair) -> None:
    bound_list, ported_list = lists_pair

    try:
        bound_list, bound_result = bound(bound_list)
    except RuntimeError:
        with pytest.raises(RuntimeError):
            ported(ported_list)
    else:
        ported_list, ported_result = ported(ported_list)

        assert are_bound_ported_bounds_lists_equal(bound_list, ported_list)
        assert are_bound_ported_intersect_nodes_lists_equal(
            bound_result, ported_result)
Exemple #8
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)
Exemple #9
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)
Exemple #10
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)
Exemple #11
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)
Exemple #12
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)
Exemple #13
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)