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_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_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_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_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_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_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_basic(polygon_with_multisegment: PolygonWithMultisegment) -> None: polygon, multisegment = polygon_with_multisegment result = symmetric_subtract_polygon_from_multisegment(multisegment, polygon) assert is_mix(result) or is_polygon(result)
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_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_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_properties(data: DataObject, coordinates_limits_type_pair: Tuple[ScalarsLimitsType, ScalarsLimitsType], sizes_pair: SizesPair, holes_sizes_pair: SizesPair, hole_sizes_pair: SizesPair) -> None: (x_coordinates_limits_type, y_coordinates_limits_type) = coordinates_limits_type_pair ((x_coordinates, (min_x_value, max_x_value)), x_type) = x_coordinates_limits_type ((y_coordinates, (min_y_value, max_y_value)), y_type) = y_coordinates_limits_type min_size, max_size = sizes_pair min_holes_size, max_holes_size = holes_sizes_pair min_hole_size, max_hole_size = hole_sizes_pair strategy = polygons(x_coordinates, y_coordinates, min_size=min_size, max_size=max_size, min_holes_size=min_holes_size, max_holes_size=max_holes_size, min_hole_size=min_hole_size, max_hole_size=max_hole_size) result = data.draw(strategy) assert is_polygon(result) assert polygon_has_valid_sizes(result, min_size=min_size, max_size=max_size, min_holes_size=min_holes_size, max_holes_size=max_holes_size, min_hole_size=min_hole_size, max_hole_size=max_hole_size) assert polygon_has_coordinates_types(result, x_type=x_type, y_type=y_type) assert polygon_has_coordinates_in_range(result, min_x_value=min_x_value, max_x_value=max_x_value, min_y_value=min_y_value, max_y_value=max_y_value) assert is_polygon_strict(result) assert is_contour_non_self_intersecting(result.border) assert all(is_contour_non_self_intersecting(hole) for hole in result.holes) assert contours_do_not_cross_or_overlap(result.holes) assert is_contour_counterclockwise(result.border) assert all(not is_contour_counterclockwise(hole) for hole in result.holes)
def test_basic(polygon_with_multisegment: PolygonWithMultisegment) -> None: polygon, multisegment = polygon_with_multisegment result = unite_multisegment_with_polygon(multisegment, polygon) assert is_mix(result) or is_polygon(result)