Beispiel #1
0
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)
Beispiel #2
0
def test_same_coordinates(data: DataObject,
                          coordinates_limits_type: ScalarsLimitsType,
                          sizes_pair: SizesPair) -> None:
    (coordinates, (min_value, max_value)), type_ = coordinates_limits_type
    min_size, max_size = sizes_pair

    strategy = concave_contours(coordinates,
                                min_size=min_size,
                                max_size=max_size)

    result = data.draw(strategy)

    assert is_contour(result)
    assert contour_has_valid_sizes(result,
                                   min_size=min_size,
                                   max_size=max_size)
    assert contour_has_coordinates_types(result, x_type=type_, y_type=type_)
    assert contour_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 are_vertices_strict(result.vertices)
    assert are_vertices_non_convex(result.vertices)
    assert is_contour_non_self_intersecting(result)
    assert is_contour_counterclockwise(result)
Beispiel #3
0
def test_properties(data: DataObject,
                    coordinates_limits_type_pair: Tuple[ScalarsLimitsType,
                                                        ScalarsLimitsType],
                    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

    strategy = concave_contours(x_coordinates,
                                y_coordinates,
                                min_size=min_size,
                                max_size=max_size)

    result = data.draw(strategy)

    assert is_contour(result)
    assert contour_has_valid_sizes(result,
                                   min_size=min_size,
                                   max_size=max_size)
    assert contour_has_coordinates_types(result, x_type=x_type, y_type=y_type)
    assert contour_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_contour_strict(result)
    assert are_vertices_non_convex(result.vertices)
    assert is_contour_non_self_intersecting(result)
    assert is_contour_counterclockwise(result)
def test_same_coordinates(data: DataObject,
                          coordinates_limits_type: ScalarsLimitsType,
                          sizes_pair: SizesPair,
                          contours_sizes_pair: SizesPair) -> None:
    (coordinates, (min_value, max_value)), type_ = coordinates_limits_type
    min_size, max_size = sizes_pair
    min_contour_size, max_contour_size = contours_sizes_pair

    strategy = multicontours(coordinates,
                             min_size=min_size,
                             max_size=max_size,
                             min_contour_size=min_contour_size,
                             max_contour_size=max_contour_size)

    result = data.draw(strategy)

    assert is_multicontour(result)
    assert has_valid_size(result, min_size=min_size, max_size=max_size)
    assert multicontour_has_valid_sizes(result,
                                        min_size=min_size,
                                        max_size=max_size,
                                        min_contour_size=min_contour_size,
                                        max_contour_size=max_contour_size)
    assert multicontour_has_coordinates_types(result,
                                              x_type=type_,
                                              y_type=type_)
    assert multicontour_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_multicontour_strict(result)
    assert all(is_contour_non_self_intersecting(contour) for contour in result)
    assert contours_do_not_cross_or_overlap(result)
    assert all(is_contour_counterclockwise(contour) for contour in result)
Beispiel #5
0
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)