def test_associativity(polygons_triplet: PolygonsTriplet) -> None: first, second, third = polygons_triplet first_second_intersection = intersect_polygons(first, second) second_third_intersection = intersect_polygons(second, third) assert (not is_polygon(first_second_intersection) or not is_polygon(second_third_intersection) or (intersect_polygons(first_second_intersection, third) == intersect_polygons(first, second_third_intersection)))
def test_difference_operand(polygons_triplet: PolygonsTriplet ) -> None: first, second, third = polygons_triplet first_second_difference = subtract_polygons(first, second) first_third_intersection = intersect_polygons(first, third) assert (not is_polygon(first_second_difference) or not is_polygon(first_third_intersection) or (intersect_polygons(first_second_difference, third) == subtract_polygons(first_third_intersection, 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_reversals(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = intersect_polygons(first, second) assert result == intersect_polygons(first, reverse_polygon_border(second)) assert result == intersect_polygons(first, reverse_polygon_holes(second)) assert result == intersect_polygons(first, reverse_polygon_holes_contours(second)) assert are_compounds_similar( result, reverse_compound_coordinates(intersect_polygons( reverse_polygon_coordinates(first), reverse_polygon_coordinates(second))))
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_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_equivalents(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = unite_polygons(first, second) first_second_symmetric_difference = symmetric_subtract_polygons( first, second) first_second_intersection = intersect_polygons(first, second) assert (not is_polygon(first_second_symmetric_difference) or not is_polygon(first_second_intersection) or result == symmetric_subtract_polygons( first_second_symmetric_difference, first_second_intersection))
def test_commutativity(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = intersect_polygons(first, second) assert result == intersect_polygons(second, first)
def test_idempotence(polygon: Polygon) -> None: result = intersect_polygons(polygon, polygon) assert are_compounds_similar(result, polygon)
def test_basic(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = intersect_polygons(first, second) assert is_maybe_shaped(result)
def test_connection_with_intersect(polygons_pair: PolygonsPair) -> None: first, second = polygons_pair result = complete_intersect_polygons(first, second) assert compound_to_shaped(result) == intersect_polygons(first, second)