Exemplo n.º 1
0
def test_mixes_relations(mixes_pair: Tuple[Mix, Mix]) -> None:
    left_mix, right_mix = mixes_pair

    result = left_mix.relate(right_mix)

    assert equivalence(
        result is Relation.DISJOINT,
        all(
            left_component.relate(right_component) is Relation.DISJOINT
            for left_component, right_component in product(
                mix_to_components(left_mix), mix_to_components(right_mix))))
    assert implication(
        result is Relation.OVERLAP,
        left_mix.shaped is right_mix.shaped is EMPTY
        or left_mix.shaped is not EMPTY and right_mix.shaped is not EMPTY)
    assert implication(result in (Relation.COVER, Relation.ENCLOSES),
                       right_mix.shaped is not EMPTY)
    assert implication(
        result is Relation.COMPOSITE,
        all(component is EMPTY
            or right_mix.relate(component) is Relation.COMPONENT
            for component in mix_to_components(left_mix)))
    assert equivalence(
        result is Relation.EQUAL,
        all(left_component is right_component is EMPTY or (
            left_component.relate(right_component) is Relation.EQUAL)
            for left_component, right_component in zip(
                mix_to_components(left_mix), mix_to_components(right_mix))))
    assert implication(
        result is Relation.COMPONENT,
        all(component is EMPTY
            or left_mix.relate(component) is Relation.COMPONENT
            for component in mix_to_components(right_mix)))
    assert implication(result in (Relation.ENCLOSED, Relation.WITHIN),
                       left_mix.shaped is not EMPTY)
Exemplo n.º 2
0
def test_connection_with_multisegment_in_contour(
        region_with_multisegment: Tuple[Region, Multisegment]) -> None:
    region, multisegment = region_with_multisegment

    result = multisegment_in_region(multisegment, region)

    relation_with_contour = multisegment_in_contour(multisegment, region)
    assert implication(result is Relation.DISJOINT,
                       relation_with_contour is Relation.DISJOINT)
    assert implication(
        result is Relation.TOUCH, relation_with_contour is Relation.TOUCH
        or relation_with_contour is Relation.OVERLAP)
    assert implication(
        result is Relation.CROSS, relation_with_contour is not Relation.EQUAL
        or relation_with_contour is not Relation.COMPONENT)
    assert implication(relation_with_contour is Relation.CROSS,
                       result is Relation.CROSS)
    assert equivalence(result is Relation.COMPONENT,
                       relation_with_contour is Relation.COMPONENT)
    assert implication(
        result is Relation.ENCLOSED, relation_with_contour is Relation.TOUCH
        or relation_with_contour is Relation.OVERLAP)
    assert implication(result is Relation.WITHIN,
                       relation_with_contour is Relation.DISJOINT)
    assert implication(
        relation_with_contour is Relation.DISJOINT, result is Relation.DISJOINT
        or result is Relation.CROSS or result is Relation.WITHIN)
    assert implication(
        relation_with_contour is Relation.TOUCH, result is Relation.TOUCH
        or result is Relation.CROSS or result is Relation.ENCLOSED)
    assert implication(
        relation_with_contour is Relation.OVERLAP, result is Relation.TOUCH
        or result is Relation.CROSS or result is Relation.ENCLOSED)
def test_step(multipolygon_with_multisegment: Tuple[Multipolygon, Multisegment]
              ) -> None:
    multipolygon, multisegment = multipolygon_with_multisegment
    first_segment, rest_multisegment = multisegment_pop_left(multisegment)

    result = multisegment_in_multipolygon(rest_multisegment, multipolygon)
    next_result = multisegment_in_multipolygon(multisegment, multipolygon)

    relation_with_first_segment = segment_in_multipolygon(first_segment,
                                                          multipolygon)
    assert equivalence(next_result is Relation.DISJOINT,
                       result is relation_with_first_segment
                       is Relation.DISJOINT)
    assert implication(next_result is Relation.TOUCH,
                       result is Relation.TOUCH
                       and relation_with_first_segment is not Relation.CROSS
                       or result is Relation.DISJOINT
                       and relation_with_first_segment is Relation.TOUCH)
    assert implication(result is Relation.DISJOINT
                       and relation_with_first_segment is Relation.TOUCH
                       or result is Relation.TOUCH
                       and relation_with_first_segment is Relation.DISJOINT,
                       next_result is Relation.TOUCH)
    assert equivalence(next_result is Relation.CROSS,
                       result is Relation.CROSS
                       or relation_with_first_segment is Relation.CROSS
                       or (bool(rest_multisegment.segments)
                           and result is Relation.DISJOINT
                           or result is Relation.TOUCH)
                       and (relation_with_first_segment is Relation.ENCLOSED
                            or relation_with_first_segment is Relation.WITHIN)
                       or (result is Relation.ENCLOSED
                           or result is Relation.WITHIN)
                       and (relation_with_first_segment is Relation.DISJOINT
                            or relation_with_first_segment is Relation.TOUCH))
    assert equivalence(next_result is Relation.COMPONENT,
                       (not rest_multisegment.segments
                        or result is Relation.COMPONENT)
                       and relation_with_first_segment is Relation.COMPONENT)
    assert equivalence(next_result is Relation.ENCLOSED,
                       not rest_multisegment.segments
                       and relation_with_first_segment is Relation.ENCLOSED
                       or (result is Relation.COMPONENT
                           or result is Relation.ENCLOSED)
                       and (relation_with_first_segment is Relation.ENCLOSED
                            or relation_with_first_segment is Relation.WITHIN)
                       or (result is Relation.ENCLOSED
                           or result is Relation.WITHIN)
                       and relation_with_first_segment is Relation.COMPONENT
                       or result is Relation.WITHIN
                       and relation_with_first_segment is Relation.ENCLOSED)
    assert equivalence(next_result is Relation.WITHIN,
                       (not rest_multisegment.segments
                        or result is Relation.WITHIN)
                       and relation_with_first_segment is Relation.WITHIN)
Exemplo n.º 4
0
def test_without_holes(polygon_with_point: Tuple[Polygon, Point]) -> None:
    polygon, point = polygon_with_point

    result = point_in_polygon(point, polygon)

    polygon_without_holes = to_solid_polygon(polygon)
    assert implication(
        result is Location.INTERIOR,
        point_in_polygon(point, polygon_without_holes) is Location.INTERIOR)
    assert implication(
        point_in_polygon(point, polygon_without_holes) is Location.EXTERIOR,
        result is Location.EXTERIOR)
    assert implication(
        point_in_polygon(point, polygon_without_holes) is Location.BOUNDARY,
        result is Location.BOUNDARY)
Exemplo n.º 5
0
def test_transitivity(segments_triplet: Tuple[PortedSegment, PortedSegment,
                                              PortedSegment]) -> None:
    first_segment, second_segment, third_segment = segments_triplet

    assert implication(first_segment == second_segment
                       and second_segment == third_segment,
                       first_segment == third_segment)
Exemplo n.º 6
0
def test_transitivity(first_operation: BoundOperation,
                      second_operation: BoundOperation,
                      third_operation: BoundOperation) -> None:
    assert implication(
        first_operation == second_operation
        and second_operation == third_operation,
        first_operation == third_operation)
Exemplo n.º 7
0
def test_connection_with_deserializer(
        string_with_deserializer: Tuple[str, Callable[[str], Base]]) -> None:
    string, deserializer = string_with_deserializer

    result = deserializer(string)

    assert implication(not result.exists(), not isinstance(result, Directory))
Exemplo n.º 8
0
def test_transitivity(first_bounding_box: BoundingBox,
                      second_bounding_box: BoundingBox,
                      third_bounding_box: BoundingBox) -> None:
    assert implication(
        first_bounding_box == second_bounding_box
        and second_bounding_box == third_bounding_box,
        first_bounding_box == third_bounding_box)
Exemplo n.º 9
0
def test_transitivity(segments_triplet: Tuple[Segment, Segment, Segment]
                      ) -> None:
    left_segment, mid_segment, right_segment = segments_triplet

    assert implication(left_segment == mid_segment
                       and mid_segment == right_segment,
                       left_segment == right_segment)
Exemplo n.º 10
0
def test_transitivity(first_ring_manager: RingManager,
                      second_ring_manager: RingManager,
                      third_ring_manager: RingManager) -> None:
    assert implication(
        first_ring_manager == second_ring_manager
        and second_ring_manager == third_ring_manager,
        first_ring_manager == third_ring_manager)
Exemplo n.º 11
0
def test_transitivity(first_intersect_node: IntersectNode,
                      second_intersect_node: IntersectNode,
                      third_intersect_node: IntersectNode) -> None:
    assert implication(
        first_intersect_node == second_intersect_node
        and second_intersect_node == third_intersect_node,
        first_intersect_node == third_intersect_node)
Exemplo n.º 12
0
def test_transitivity(first_local_minimum_list: LocalMinimumList,
                      second_local_minimum_list: LocalMinimumList,
                      third_local_minimum_list: LocalMinimumList) -> None:
    assert implication(
        first_local_minimum_list == second_local_minimum_list
        and second_local_minimum_list == third_local_minimum_list,
        first_local_minimum_list == third_local_minimum_list)
Exemplo n.º 13
0
def test_transitivity(trapezoids_triplet: Tuple[Trapezoid, Trapezoid,
                                                Trapezoid]) -> None:
    first_trapezoid, second_trapezoid, third_trapezoid = trapezoids_triplet

    assert implication(first_trapezoid == second_trapezoid
                       and second_trapezoid == third_trapezoid,
                       first_trapezoid == third_trapezoid)
Exemplo n.º 14
0
def test_transitivity(
        multipoints_triplet: Tuple[Multipoint, Multipoint,
                                   Multipoint]) -> None:
    left_multipoint, mid_multipoint, right_multipoint = multipoints_triplet

    assert implication(left_multipoint == mid_multipoint == right_multipoint,
                       left_multipoint == right_multipoint)
Exemplo n.º 15
0
def test_transitivity(points_triplet: Tuple[Point, Point, Point]) -> None:
    first_point, second_point, third_point = points_triplet

    assert implication(
        first_point.is_right_of(second_point)
        and second_point.is_right_of(third_point),
        first_point.is_right_of(third_point))
Exemplo n.º 16
0
def test_transitivity(first_multipolygon: Multipolygon,
                      second_multipolygon: Multipolygon,
                      third_multipolygon: Multipolygon) -> None:
    assert implication(
        first_multipolygon == second_multipolygon
        and second_multipolygon == third_multipolygon,
        first_multipolygon == third_multipolygon)
Exemplo n.º 17
0
def test_transitivity(first_linear_ring: LinearRing,
                      second_linear_ring: LinearRing,
                      third_linear_ring: LinearRing) -> None:
    assert implication(
        first_linear_ring == second_linear_ring
        and second_linear_ring == third_linear_ring,
        first_linear_ring == third_linear_ring)
Exemplo n.º 18
0
def test_expected_args(
        signature_with_expected_args: Tuple[models.Base, Args]) -> None:
    signature, expected_args = signature_with_expected_args

    result = signature.bind(*expected_args)

    assert implication(bool(expected_args), result != signature)
Exemplo n.º 19
0
def test_connection_with_disjoint(
        compounds_pair: Tuple[Compound, Compound]) -> None:
    left_compound, right_compound = compounds_pair

    result = left_compound - right_compound

    assert implication(left_compound.disjoint(right_compound),
                       are_compounds_equivalent(result, left_compound))
Exemplo n.º 20
0
def test_transitivity(
    keys_pair: Tuple[PortedEventsQueueKey, PortedEventsQueueKey,
                     PortedEventsQueueKey]
) -> None:
    first_key, second_key, third_key = keys_pair

    assert implication(first_key == second_key and second_key == third_key,
                       first_key == third_key)
Exemplo n.º 21
0
def test_transitivity(
    contours_triplet: Tuple[PortedContour, PortedContour,
                            PortedContour]) -> None:
    first_contour, second_contour, third_contour = contours_triplet

    assert implication(
        first_contour == second_contour and second_contour == third_contour,
        first_contour == third_contour)
Exemplo n.º 22
0
def test_transitivity(events_triplet: Tuple[PortedSweepEvent,
                                            PortedSweepEvent,
                                            PortedSweepEvent]) -> None:
    first_event, second_event, third_event = events_triplet

    assert implication(first_event == second_event
                       and second_event == third_event,
                       first_event == third_event)
Exemplo n.º 23
0
def test_expected_kwargs(
        signature_with_expected_kwargs: Tuple[models.Base, Kwargs]) -> None:
    signature, expected_kwargs = signature_with_expected_kwargs
    result = signature.bind(**expected_kwargs)

    assert implication(
        bool(expected_kwargs),
        signature_parameters_has_defaults(result, names=expected_kwargs))
Exemplo n.º 24
0
def test_transitivity(
    keys_triplet: Tuple[PortedSweepLineKey, PortedSweepLineKey,
                        PortedSweepLineKey]
) -> None:
    first_key, second_key, third_key = keys_triplet

    assert implication(first_key == second_key and second_key == third_key,
                       first_key == third_key)
Exemplo n.º 25
0
def test_transitivity(
    polygons_triplet: Tuple[PortedPolygon, PortedPolygon,
                            PortedPolygon]) -> None:
    first_polygon, second_polygon, third_polygon = polygons_triplet

    assert implication(
        first_polygon == second_polygon and second_polygon == third_polygon,
        first_polygon == third_polygon)
def test_properties(multisegment_with_segment: MultisegmentWithSegment
                    ) -> None:
    multisegment, segment = multisegment_with_segment

    result = subtract_multisegment_from_segment(segment, multisegment)

    relation = segment_in_multisegment(segment, multisegment)
    assert equivalence(is_empty(result),
                       relation is Relation.EQUAL
                       or relation is Relation.COMPONENT)
    assert implication(is_multisegment(result),
                       relation in (Relation.TOUCH, Relation.CROSS,
                                    Relation.COMPOSITE, Relation.OVERLAP))
    assert implication(is_segment(result),
                       relation in (Relation.DISJOINT, Relation.TOUCH,
                                    Relation.CROSS, Relation.COMPOSITE,
                                    Relation.OVERLAP))
Exemplo n.º 27
0
def test_transitivity(
    keys_triplet: Tuple[BoundEventsQueueKey, BoundEventsQueueKey,
                        BoundEventsQueueKey]
) -> None:
    first_key, second_key, third_key = keys_triplet

    assert implication(first_key < second_key < third_key,
                       first_key < third_key)
Exemplo n.º 28
0
def test_transitivity(multipolygons_triplet: Tuple[Multipolygon, Multipolygon,
                                                   Multipolygon]) -> None:
    (left_multipolygon, mid_multipolygon,
     right_multipolygon) = multipolygons_triplet

    assert implication(left_multipolygon == mid_multipolygon
                       == right_multipolygon,
                       left_multipolygon == right_multipolygon)
Exemplo n.º 29
0
def test_connection_with_disjoint(
        compounds_pair: Tuple[Compound, Compound]) -> None:
    left_compound, right_compound = compounds_pair

    result = left_compound ^ right_compound

    assert implication(left_compound.disjoint(right_compound),
                       result == left_compound | right_compound)
Exemplo n.º 30
0
def test_convex_polygon(polygon: Polygon) -> None:
    polygon_with_convex_border = to_polygon_with_convex_border(polygon)
    assert (bool(polygon.holes)
            or implication(
                    are_polygons_equivalent(polygon,
                                            polygon_with_convex_border),
                    all(segment_in_polygon(segment, polygon)
                        is Relation.ENCLOSED
                        for segment in to_contour_separators(polygon.border))))