def test_invalid_holes_sizes(coordinates: Strategy[Scalar], invalid_sizes_pair: SizesPair) -> None: min_hole_size, max_hole_size = invalid_sizes_pair with pytest.raises(ValueError): multipolygons(coordinates, min_hole_size=min_hole_size, max_hole_size=max_hole_size)
def test_non_valid_holes_sizes(coordinates: Strategy[Scalar], non_valid_sizes_pair: SizesPair) -> None: min_size, max_size = non_valid_sizes_pair with pytest.warns(HypothesisWarning) as warnings: multipolygons(coordinates, min_hole_size=min_size, max_hole_size=max_size) assert len(warnings) == 1
def test_same_coordinates(data: DataObject, coordinates_limits_type: ScalarsLimitsType, sizes_pair: SizesPair, border_sizes_pair: SizesPair, holes_sizes_pair: SizesPair, hole_sizes_pair: SizesPair) -> None: (coordinates, (min_value, max_value)), type_ = coordinates_limits_type min_size, max_size = sizes_pair min_border_size, max_border_size = border_sizes_pair min_holes_size, max_holes_size = holes_sizes_pair min_hole_size, max_hole_size = hole_sizes_pair strategy = multipolygons(coordinates, min_size=min_size, max_size=max_size, min_border_size=min_border_size, max_border_size=max_border_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_multipolygon(result) assert multipolygon_has_valid_sizes(result, min_size=min_size, max_size=max_size, min_border_size=min_border_size, max_border_size=max_border_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 multipolygon_has_coordinates_types(result, x_type=type_, y_type=type_) assert multipolygon_has_coordinates_in_range(result, min_x_value=min_value, max_x_value=max_value, min_y_value=min_value, max_y_value=max_value) assert is_multipolygon_strict(result) assert all( is_contour_non_self_intersecting(polygon.border) and all( is_contour_non_self_intersecting(hole) for hole in polygon.holes) for polygon in result.polygons) assert contours_do_not_cross_or_overlap( [polygon.border for polygon in result.polygons]) assert all( contours_do_not_cross_or_overlap(polygon.holes) for polygon in result.polygons) assert all( is_contour_counterclockwise(polygon.border) and all( not is_contour_counterclockwise(hole) for hole in polygon.holes) for polygon in result.polygons)
def test_basic(coordinates: Strategy[Scalar], sizes_pair: SizesPair, border_sizes_pair: SizesPair, holes_sizes_pair: SizesPair, hole_sizes_pair: SizesPair) -> None: min_size, max_size = sizes_pair min_border_size, max_border_size = border_sizes_pair min_holes_size, max_holes_size = holes_sizes_pair min_hole_size, max_hole_size = hole_sizes_pair result = multipolygons(coordinates, min_size=min_size, max_size=max_size, min_border_size=min_border_size, max_border_size=max_border_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 isinstance(result, Strategy)
from hypothesis import strategies from hypothesis_geometry import planar from tests.binding_tests.utils import (bound_fill_kinds, bound_polygon_kinds) from tests.integration_tests.utils import ( to_bound_with_ported_linear_rings_pair, to_bound_with_ported_multipolygons_pair, to_bound_with_ported_points_lists_pair, to_bound_with_ported_polygons_pair, to_bound_with_ported_wagyus_pair) from tests.port_tests.utils import (ported_fill_kinds, ported_polygon_kinds) from tests.strategies import coordinates booleans = strategies.booleans() wagyus_pairs = strategies.builds(to_bound_with_ported_wagyus_pair, booleans) linear_rings_points_pairs = ( planar.contours(coordinates).map(to_bound_with_ported_points_lists_pair)) linear_rings_pairs = ( linear_rings_points_pairs.map(to_bound_with_ported_linear_rings_pair)) polygons_pairs = ( planar.polygons(coordinates).map(to_bound_with_ported_polygons_pair)) polygon_kinds_pairs = strategies.sampled_from( list(zip(bound_polygon_kinds, ported_polygon_kinds))) multipolygons_pairs = (planar.multipolygons(coordinates).map( to_bound_with_ported_multipolygons_pair)) fill_kinds_pairs = strategies.sampled_from( list(zip(bound_fill_kinds, ported_fill_kinds)))
from _wagyu import Multipolygon from hypothesis import strategies from hypothesis_geometry import planar from tests.binding_tests.utils import to_bound_multipolygon_polygons from tests.strategies import coordinates polygons_lists = (planar.multipolygons(coordinates) .map(to_bound_multipolygon_polygons)) multipolygons = strategies.builds(Multipolygon, polygons_lists)
def coordinates_to_multipolygons_with_multisegments( coordinates: Strategy[Coordinate] ) -> Strategy[Tuple[Multipolygon, Multisegment]]: return strategies.tuples(planar.multipolygons(coordinates), planar.multisegments(coordinates))