def test_reversals(polygon_with_segment: PolygonWithSegment) -> None: polygon, segment = polygon_with_segment result = symmetric_subtract_polygon_from_segment(segment, polygon) assert are_compounds_similar( result, symmetric_subtract_polygon_from_segment( segment, reverse_polygon_border(polygon))) assert are_compounds_similar( result, symmetric_subtract_polygon_from_segment( segment, reverse_polygon_holes(polygon))) assert are_compounds_similar( result, symmetric_subtract_polygon_from_segment( segment, reverse_polygon_holes_contours(polygon))) assert are_compounds_similar( result, symmetric_subtract_polygon_from_segment(reverse_segment(segment), polygon)) assert are_compounds_similar( result, reverse_compound_coordinates( symmetric_subtract_polygon_from_segment( reverse_segment_coordinates(segment), reverse_polygon_coordinates(polygon))))
def test_reversals(segments_pair: SegmentsPair) -> None: first, second = segments_pair result = unite_segments(first, second) assert are_compounds_similar( result, unite_segments(first, reverse_segment(second))) assert are_compounds_similar( result, reverse_compound_coordinates( unite_segments(reverse_segment_coordinates(first), reverse_segment_coordinates(second))))
def test_reversals(multisegments_pair: MultisegmentsPair) -> None: first, second = multisegments_pair result = symmetric_subtract_multisegments(first, second) assert are_compounds_similar( result, symmetric_subtract_multisegments(first, reverse_multisegment(second))) assert are_compounds_similar( result, reverse_compound_coordinates( symmetric_subtract_multisegments( reverse_multisegment_coordinates(first), reverse_multisegment_coordinates(second))))
def test_reversals(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = unite_polygons(first, second) assert are_compounds_similar( result, unite_polygons(first, reverse_polygon_border(second))) assert are_compounds_similar( result, unite_polygons(first, reverse_polygon_holes(second))) assert are_compounds_similar( result, unite_polygons(first, reverse_polygon_holes_contours(second))) assert are_compounds_similar( result, reverse_compound_coordinates( unite_polygons(reverse_polygon_coordinates(first), reverse_polygon_coordinates(second))))
def test_associativity(multisegments_triplet: MultisegmentsTriplet) -> None: first, second, third = multisegments_triplet result = unite_multisegments(unite_multisegments(first, second), third) assert are_compounds_similar( result, unite_multisegments(first, unite_multisegments(second, third)))
def test_absorption_identity(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair first_second_union = unite_polygons(first, second) assert (not is_polygon(first_second_union) or are_compounds_similar( intersect_polygons(first_second_union, first), first))
def test_commutativity(segments_pair: SegmentsPair) -> None: first, second = segments_pair result = symmetric_subtract_segments(first, second) assert are_compounds_similar(result, symmetric_subtract_segments(second, first))
def test_associativity(polygons_triplet: PolygonsTriplet) -> None: first, second, third = polygons_triplet first_second_union = unite_polygons(first, second) second_third_union = unite_polygons(second, third) assert (not is_polygon(first_second_union) or not is_polygon(second_third_union) or are_compounds_similar( unite_polygons(first_second_union, third), unite_polygons(first, second_third_union)))
def test_associativity(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_union = unite_segments(first, second) second_third_union = unite_segments(second, third) assert (not is_segment(first_second_union) or not is_segment(second_third_union) or are_compounds_similar( unite_segments(first_second_union, third), unite_segments(first, second_third_union)))
def test_intersection_minuend(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_intersection = intersect_segments(first, second) second_third_difference = subtract_segments(second, third) assert (not is_segment(first_second_intersection) or not is_segment(second_third_difference) or are_compounds_similar( subtract_segments(first_second_intersection, third), intersect_segments(first, second_third_difference)))
def test_reversals(multisegment_with_segment: MultisegmentWithSegment) -> None: multisegment, segment = multisegment_with_segment result = unite_segment_with_multisegment(segment, multisegment) assert are_compounds_similar( result, unite_segment_with_multisegment( segment, reverse_multisegment(multisegment))) assert are_compounds_similar( result, unite_segment_with_multisegment( segment, reverse_multisegment_endpoints(multisegment))) assert are_compounds_similar( result, unite_segment_with_multisegment(reverse_segment(segment), multisegment)) assert are_compounds_similar( result, reverse_compound_coordinates( unite_segment_with_multisegment( reverse_segment_coordinates(segment), reverse_multisegment_coordinates(multisegment))))
def test_equivalents(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = intersect_polygons(first, second) first_second_difference = subtract_polygons(first, second) assert (not is_polygon(first_second_difference) or are_compounds_similar(result, subtract_polygons( first, first_second_difference)))
def test_reversals(regions_pair: RegionsPair) -> None: first, second = regions_pair result = complete_intersect_regions(first, second) assert result == complete_intersect_regions(first, reverse_region(second)) assert are_compounds_similar( result, reverse_compound_coordinates(complete_intersect_regions( reverse_region_coordinates(first), reverse_region_coordinates(second))))
def test_equivalents(segments_pair: SegmentsPair) -> None: first, second = segments_pair result = symmetric_subtract_segments(first, second) first_second_difference = subtract_segments(first, second) first_second_union = unite_segments(first, second) second_first_difference = subtract_segments(second, first) second_first_intersection = intersect_segments(second, first) assert (not is_segment(second_first_intersection) or not is_segment(first_second_union) or are_compounds_similar( result, subtract_segments(first_second_union, second_first_intersection))) assert (not is_segment(first_second_difference) or not is_segment(second_first_difference) or are_compounds_similar( result, unite_segments(first_second_difference, second_first_difference)))
def test_union_subtrahend(multisegments_triplet: MultisegmentsTriplet) -> None: first, second, third = multisegments_triplet first_second_difference = subtract_multisegments(first, second) first_third_difference = subtract_multisegments(first, third) assert (not is_multisegment(first_second_difference) or not is_multisegment(first_third_difference) or are_compounds_similar( subtract_multisegments(first, unite_multisegments( second, third)), intersect_multisegments(first_second_difference, first_third_difference)))
def test_reversals(multisegments_pair: MultisegmentsPair) -> None: first, second = multisegments_pair result = complete_intersect_multisegments(first, second) assert result == complete_intersect_multisegments( first, reverse_multisegment(second)) assert are_compounds_similar( result, reverse_compound_coordinates( complete_intersect_multisegments( reverse_multisegment_coordinates(first), reverse_multisegment_coordinates(second))))
def test_distribution_over_intersection( polygons_triplet: PolygonsTriplet) -> None: first, second, third = polygons_triplet second_third_intersection = intersect_polygons(second, third) first_second_union = unite_polygons(first, second) first_third_union = unite_polygons(first, third) assert (not is_polygon(second_third_intersection) or not is_polygon(first_second_union) or not is_polygon(first_third_union) or are_compounds_similar( unite_polygons(first, second_third_intersection), intersect_polygons(first_second_union, first_third_union)))
def test_properties(polygon_with_segment: PolygonWithSegment) -> None: polygon, segment = polygon_with_segment result = symmetric_subtract_polygon_from_segment(segment, polygon) relation = segment_in_polygon(segment, polygon) assert (not is_mix(result) or (relation in (Relation.DISJOINT, Relation.TOUCH, Relation.CROSS) and (is_empty(result.discrete) and not is_empty(result.linear) and are_compounds_similar(result.shaped, polygon)))) assert (not is_polygon(result) or relation in (Relation.COMPONENT, Relation.ENCLOSED, Relation.WITHIN))
def test_difference_operand(polygons_triplet: PolygonsTriplet) -> None: first, second, third = polygons_triplet first_second_difference = subtract_polygons(first, second) first_third_union = unite_polygons(first, third) second_third_difference = subtract_polygons(second, third) assert (not is_polygon(first_second_difference) or not is_polygon(first_third_union) or not is_polygon(second_third_difference) or are_compounds_similar( unite_polygons(first_second_difference, third), subtract_polygons(first_third_union, second_third_difference)))
def test_difference_operand(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_difference = subtract_segments(first, second) first_third_union = unite_segments(first, third) second_third_difference = subtract_segments(second, third) assert (not is_segment(first_second_difference) or not is_segment(first_third_union) or not is_segment(second_third_difference) or are_compounds_similar( unite_segments(first_second_difference, third), subtract_segments(first_third_union, second_third_difference)))
def test_reversals(polygon_with_multisegment: PolygonWithMultisegment) -> None: polygon, multisegment = polygon_with_multisegment result = unite_multisegment_with_polygon(multisegment, polygon) assert are_compounds_similar( result, unite_multisegment_with_polygon(multisegment, reverse_polygon_border(polygon))) assert are_compounds_similar( result, unite_multisegment_with_polygon(multisegment, reverse_polygon_holes(polygon))) assert are_compounds_similar( result, unite_multisegment_with_polygon( multisegment, reverse_polygon_holes_contours(polygon))) assert are_compounds_similar( result, unite_multisegment_with_polygon(reverse_multisegment(multisegment), polygon)) assert are_compounds_similar( result, unite_multisegment_with_polygon( reverse_multisegment_endpoints(multisegment), polygon)) assert are_compounds_similar( result, reverse_compound_coordinates( unite_multisegment_with_polygon( reverse_multisegment_coordinates(multisegment), reverse_polygon_coordinates(polygon))))
def test_repeated(polygons_triplet: PolygonsTriplet) -> None: first, second, third = polygons_triplet first_second_symmetric_difference = symmetric_subtract_polygons( first, second) second_third_symmetric_difference = symmetric_subtract_polygons( second, third) assert (not is_polygon(first_second_symmetric_difference) or not is_polygon(second_third_symmetric_difference) or are_compounds_similar( symmetric_subtract_polygons(first_second_symmetric_difference, second_third_symmetric_difference), symmetric_subtract_polygons(first, third)))
def test_properties( polygon_with_multisegment: PolygonWithMultisegment) -> None: polygon, multisegment = polygon_with_multisegment result = unite_multisegment_with_polygon(multisegment, polygon) relation = multisegment_in_polygon(multisegment, polygon) assert (not is_mix(result) or (relation in (Relation.DISJOINT, Relation.TOUCH, Relation.CROSS) and (is_empty(result.discrete) and not is_empty(result.linear) and are_compounds_similar(result.shaped, polygon)))) assert (not is_polygon(result) or relation in (Relation.COMPONENT, Relation.ENCLOSED, Relation.WITHIN))
def test_difference_subtrahend(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_difference = subtract_segments(first, second) first_third_difference = intersect_segments(first, third) second_third_difference = subtract_segments(second, third) assert (not is_segment(first_second_difference) or not is_segment(first_third_difference) or not is_segment(second_third_difference) or are_compounds_similar( subtract_segments(first, second_third_difference), unite_segments(first_second_difference, first_third_difference)))
def test_repeated(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_symmetric_difference = symmetric_subtract_segments( first, second) second_third_symmetric_difference = symmetric_subtract_segments( second, third) assert (not is_segment(first_second_symmetric_difference) or not is_segment(second_third_symmetric_difference) or are_compounds_similar( symmetric_subtract_segments(first_second_symmetric_difference, second_third_symmetric_difference), symmetric_subtract_segments(first, third)))
def test_distribution_over_intersection( segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_union = unite_segments(first, second) first_third_union = unite_segments(first, third) second_third_intersection = intersect_segments(second, third) assert (not is_segment(first_second_union) or not is_segment(first_third_union) or not is_segment(second_third_intersection) or are_compounds_similar( unite_segments(first, second_third_intersection), intersect_segments(first_second_union, first_third_union)))
def test_reversals(segments: List[Segment]) -> None: segments = segments result = segments_to_multisegment(segments) assert result == segments_to_multisegment( reverse_segments_sequence(segments)) assert result == segments_to_multisegment( reverse_segments_sequence_endpoints(segments)) assert are_compounds_similar( result, reverse_compound_coordinates( segments_to_multisegment( reverse_segments_sequence_coordinates(segments))))
def test_reversals(multisegment_with_segment: MultisegmentWithSegment) -> None: multisegment, segment = multisegment_with_segment result = symmetric_subtract_multisegment_from_segment( segment, multisegment) assert are_compounds_similar( result, symmetric_subtract_multisegment_from_segment( segment, reverse_multisegment(multisegment))) assert are_compounds_similar( result, symmetric_subtract_multisegment_from_segment( segment, reverse_multisegment_endpoints(multisegment))) assert are_compounds_similar( result, symmetric_subtract_multisegment_from_segment(reverse_segment(segment), multisegment)) assert are_compounds_similar( result, reverse_compound_coordinates( symmetric_subtract_multisegment_from_segment( reverse_segment_coordinates(segment), reverse_multisegment_coordinates(multisegment))))
def test_reversals(polygon_with_segment: PolygonWithSegment ) -> None: polygon, segment = polygon_with_segment result = complete_intersect_segment_with_polygon(segment, polygon) assert result == complete_intersect_segment_with_polygon( segment, reverse_polygon_border(polygon)) assert result == complete_intersect_segment_with_polygon( segment, reverse_polygon_holes(polygon)) assert result == complete_intersect_segment_with_polygon( segment, reverse_polygon_holes_contours(polygon)) assert result == complete_intersect_segment_with_polygon( reverse_segment(segment), polygon) assert are_compounds_similar( result, reverse_compound_coordinates( complete_intersect_segment_with_polygon( reverse_segment_coordinates(segment), reverse_polygon_coordinates(polygon))))
def test_commutativity(segments_pair: SegmentsPair) -> None: first, second = segments_pair result = intersect_segments(first, second) assert are_compounds_similar(result, intersect_segments(second, first))