Welcome to hypothesis_geometry’s documentation!

Note

If object is not listed in documentation it should be considered as implementation detail that can change and should not be relied upon.

hypothesis_geometry.planar.points(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[Tuple[numbers.Real, numbers.Real]][source]

Returns a strategy for points. Point is a pair of numbers.

Parameters
  • x_coordinates – strategy for points’ x-coordinates.

  • y_coordinates – strategy for points’ y-coordinates, None for reusing x-coordinates strategy.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> points = planar.points(coordinates)
>>> point = points.example()
>>> isinstance(point, tuple)
True
>>> len(point) == 2
True
>>> all(isinstance(coordinate, coordinates_type)
...     for coordinate in point)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for coordinate in point)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> points = planar.points(x_coordinates, y_coordinates)
>>> point = points.example()
>>> isinstance(point, tuple)
True
>>> len(point) == 2
True
>>> all(isinstance(coordinate, coordinates_type)
...     for coordinate in point)
True
>>> point_x, point_y = point
>>> min_x_coordinate <= point_x <= max_x_coordinate
True
>>> min_y_coordinate <= point_y <= max_y_coordinate
True
hypothesis_geometry.planar.multipoints(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 0, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for multipoints. Multipoint is a possibly empty sequence of distinct points.

Parameters
  • x_coordinates – strategy for points’ x-coordinates.

  • y_coordinates – strategy for points’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for multipoint size.

  • max_size – upper bound for multipoint size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> multipoints = planar.multipoints(coordinates,
...                                  min_size=min_size,
...                                  max_size=max_size)
>>> multipoint = multipoints.example()
>>> isinstance(multipoint, list)
True
>>> min_size <= len(multipoint) <= max_size
True
>>> all(isinstance(point, tuple) for point in multipoint)
True
>>> all(len(point) == 2 for point in multipoint)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for point in multipoint
...     for coordinate in point)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for point in multipoint
...     for coordinate in point)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> multipoints = planar.multipoints(x_coordinates, y_coordinates,
...                                      min_size=min_size,
...                                      max_size=max_size)
>>> multipoint = multipoints.example()
>>> isinstance(multipoint, list)
True
>>> min_size <= len(multipoint) <= max_size
True
>>> all(isinstance(point, tuple) for point in multipoint)
True
>>> all(len(point) == 2 for point in multipoint)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for point in multipoint
...     for coordinate in point)
True
>>> all(min_x_coordinate <= point_x <= max_x_coordinate
...     and min_y_coordinate <= point_y <= max_y_coordinate
...     for point_x, point_y in multipoint)
True
hypothesis_geometry.planar.segments(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[Tuple[Tuple[numbers.Real, numbers.Real], Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for segments. Segment is a pair of unequal points.

Parameters
  • x_coordinates – strategy for endpoints’ x-coordinates.

  • y_coordinates – strategy for endpoints’ y-coordinates, None for reusing x-coordinates strategy.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> segments = planar.segments(coordinates)
>>> segment = segments.example()
>>> isinstance(segment, tuple)
True
>>> len(segment) == 2
True
>>> all(isinstance(endpoint, tuple) for endpoint in segment)
True
>>> all(len(endpoint) == 2 for endpoint in segment)
True
>>> all(all(isinstance(coordinate, coordinates_type)
...         for coordinate in endpoint)
...     for endpoint in segment)
True
>>> all(all(min_coordinate <= coordinate <= max_coordinate
...         for coordinate in endpoint)
...     for endpoint in segment)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> segments = planar.segments(x_coordinates, y_coordinates)
>>> segment = segments.example()
>>> isinstance(segment, tuple)
True
>>> len(segment) == 2
True
>>> all(isinstance(endpoint, tuple) for endpoint in segment)
True
>>> all(len(endpoint) == 2 for endpoint in segment)
True
>>> all(all(isinstance(coordinate, coordinates_type)
...         for coordinate in endpoint)
...     for endpoint in segment)
True
>>> all(min_x_coordinate <= endpoint_x <= max_x_coordinate
...     and min_y_coordinate <= endpoint_y <= max_y_coordinate
...     for endpoint_x, endpoint_y in segment)
True
hypothesis_geometry.planar.multisegments(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 0, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[Tuple[numbers.Real, numbers.Real], Tuple[numbers.Real, numbers.Real]]]][source]

Returns a strategy for multisegments. Multisegment is a possibly empty sequence of segments such that any pair of them do not cross/overlap each other.

Parameters
  • x_coordinates – strategy for segments’ x-coordinates.

  • y_coordinates – strategy for segments’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for multisegment size.

  • max_size – upper bound for multisegment size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> multisegments = planar.multisegments(coordinates,
...                                      min_size=min_size,
...                                      max_size=max_size)
>>> multisegment = multisegments.example()
>>> isinstance(multisegment, list)
True
>>> min_size <= len(multisegment) <= max_size
True
>>> all(isinstance(segment, tuple) for segment in multisegment)
True
>>> all(isinstance(endpoint, tuple)
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(len(segment) == 2 for segment in multisegment)
True
>>> all(len(endpoint) == 2
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for segment in multisegment
...     for endpoint in segment
...     for coordinate in endpoint)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for segment in multisegment
...     for endpoint in segment
...     for coordinate in endpoint)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> multisegments = planar.multisegments(x_coordinates, y_coordinates,
...                                      min_size=min_size,
...                                      max_size=max_size)
>>> multisegment = multisegments.example()
>>> isinstance(multisegment, list)
True
>>> min_size <= len(multisegment) <= max_size
True
>>> all(isinstance(segment, tuple) for segment in multisegment)
True
>>> all(isinstance(endpoint, tuple)
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(len(segment) == 2 for segment in multisegment)
True
>>> all(len(endpoint) == 2
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for segment in multisegment
...     for endpoint in segment
...     for coordinate in endpoint)
True
>>> all(min_x_coordinate <= endpoint_x <= max_x_coordinate
...     and min_y_coordinate <= endpoint_y <= max_y_coordinate
...     for segment in multisegment
...     for endpoint_x, endpoint_y in segment)
True
hypothesis_geometry.planar.polylines(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 2, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for polylines. Polyline is a sequence of points (called polyline’s vertices) such that there is no consecutive equal points.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for polyline size.

  • max_size – upper bound for polyline size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> polylines = planar.polylines(coordinates,
...                              min_size=min_size,
...                              max_size=max_size)
>>> polyline = polylines.example()
>>> isinstance(polyline, list)
True
>>> min_size <= len(polyline) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in polyline)
True
>>> all(len(vertex) == 2 for vertex in polyline)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in polyline
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in polyline
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> polylines = planar.polylines(x_coordinates, y_coordinates,
...                              min_size=min_size,
...                              max_size=max_size)
>>> polyline = polylines.example()
>>> isinstance(polyline, list)
True
>>> min_size <= len(polyline) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in polyline)
True
>>> all(len(vertex) == 2 for vertex in polyline)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in polyline
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in polyline)
True
hypothesis_geometry.planar.contours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 3, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for contours. Contour is a sequence of points (called contour’s vertices) such that line segments formed by pairs of consecutive points (including the last-first point pair) do not cross/overlap each other.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for contour size.

  • max_size – upper bound for contour size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.contours(coordinates,
...                              min_size=min_size,
...                              max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.contours(x_coordinates, y_coordinates,
...                            min_size=min_size,
...                            max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.convex_contours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 3, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for convex contours. Convex contour is a contour such that the line segment formed by any two points from contour’s line segments stays inside the region bounded by the contour.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for contour size.

  • max_size – upper bound for contour size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.convex_contours(coordinates,
...                                   min_size=min_size,
...                                   max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.contours(x_coordinates, y_coordinates,
...                            min_size=min_size,
...                            max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.concave_contours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 4, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for concave contours. Concave contour is a contour that is not convex.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for contour size.

  • max_size – upper bound for contour size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.concave_contours(coordinates,
...                                    min_size=min_size,
...                                    max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.concave_contours(x_coordinates, y_coordinates,
...                                    min_size=min_size,
...                                    max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.triangular_contours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for triangular contours. Triangular contour is a contour formed by 3 points.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> contours = planar.triangular_contours(coordinates)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> len(contour) == 3
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> contours = planar.triangular_contours(x_coordinates, y_coordinates)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> len(contour) == 3
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.rectangular_contours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for axis-aligned rectangular contours. Rectangular contour is a contour formed by 4 points.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> contours = planar.rectangular_contours(coordinates)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> len(contour) == 4
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> contours = planar.rectangular_contours(x_coordinates, y_coordinates)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> len(contour) == 4
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.bounding_boxes(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[Tuple[numbers.Real, numbers.Real, numbers.Real, numbers.Real]][source]

Returns a strategy for bounding boxes. Bounding box is a quadruple of x_min, x_max, y_min, y_max.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> bounding_boxes = planar.bounding_boxes(coordinates)
>>> bounding_box = bounding_boxes.example()
>>> isinstance(bounding_box, tuple)
True
>>> len(bounding_box) == 4
True
>>> all(isinstance(coordinate, coordinates_type)
...     for coordinate in bounding_box)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for coordinate in bounding_box)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> bounding_boxes = planar.bounding_boxes(x_coordinates, y_coordinates)
>>> bounding_box = bounding_boxes.example()
>>> isinstance(bounding_box, tuple)
True
>>> len(bounding_box) == 4
True
>>> all(isinstance(coordinate, coordinates_type)
...     for coordinate in bounding_box)
True
>>> all(min_x_coordinate <= coordinate <= max_x_coordinate
...     for coordinate in bounding_box[:2])
True
>>> all(min_y_coordinate <= coordinate <= max_y_coordinate
...     for coordinate in bounding_box[2:])
True
hypothesis_geometry.planar.star_contours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 3, max_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[numbers.Real, numbers.Real]]][source]

Returns a strategy for star contours. Star contour is a contour such that every vertex is visible from centroid, i.e. segments from centroid to vertices do not cross or overlap contour.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for contour size.

  • max_size – upper bound for contour size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.star_contours(coordinates,
...                                 min_size=min_size,
...                                 max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> contours = planar.star_contours(x_coordinates, y_coordinates,
...                                 min_size=min_size,
...                                 max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, list)
True
>>> min_size <= len(contour) <= max_size
True
>>> all(isinstance(vertex, tuple) for vertex in contour)
True
>>> all(len(vertex) == 2 for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.multicontours(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 0, max_size: Optional[int] = None, min_contour_size: int = 3, max_contour_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[List[Tuple[numbers.Real, numbers.Real]]]][source]

Returns a strategy for multicontours. Multicontour is a possibly empty sequence of non-crossing and non-overlapping contours.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for size.

  • max_size – upper bound for size, None for unbound.

  • min_contour_size – lower bound for contour size.

  • max_contour_size – upper bound for contour size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> min_contour_size, max_contour_size = 3, 5
>>> multicontours = planar.multicontours(coordinates,
...                                      min_size=min_size,
...                                      max_size=max_size,
...                                      min_contour_size=min_contour_size,
...                                      max_contour_size=max_contour_size)
>>> multicontour = multicontours.example()
>>> isinstance(multicontour, list)
True
>>> all(isinstance(contour, list) for contour in multicontour)
True
>>> min_size <= len(multicontour) <= max_size
True
>>> all(min_contour_size <= len(contour) <= max_contour_size
...     for contour in multicontour)
True
>>> all(isinstance(vertex, tuple)
...     for contour in multicontour
...     for vertex in contour)
True
>>> all(len(vertex) == 2 for contour in multicontour for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for contour in multicontour
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for contour in multicontour
...     for vertex in contour
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> min_contour_size, max_contour_size = 3, 5
>>> multicontours = planar.multicontours(x_coordinates, y_coordinates,
...                            min_size=min_size,
...                            max_size=max_size,
...                            min_contour_size=min_contour_size,
...                            max_contour_size=max_contour_size)
>>> multicontour = multicontours.example()
>>> isinstance(multicontour, list)
True
>>> all(isinstance(contour, list) for contour in multicontour)
True
>>> min_size <= len(multicontour) <= max_size
True
>>> all(min_contour_size <= len(contour) <= max_contour_size
...     for contour in multicontour)
True
>>> all(isinstance(vertex, tuple)
...     for contour in multicontour
...     for vertex in contour)
True
>>> all(len(vertex) == 2 for contour in multicontour for vertex in contour)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for contour in multicontour
...     for vertex in contour
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for contour in multicontour
...     for vertex_x, vertex_y in contour)
True
hypothesis_geometry.planar.polygons(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 3, max_size: Optional[int] = None, min_holes_size: int = 0, max_holes_size: Optional[int] = None, min_hole_size: int = 3, max_hole_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[Tuple[List[Tuple[numbers.Real, numbers.Real]], List[List[Tuple[numbers.Real, numbers.Real]]]]][source]

Returns a strategy for polygons. Polygon is a pair of contour (called polygon’s border) and multicontour which lies within the border (called polygon’s holes).

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for border size.

  • max_size – upper bound for border size, None for unbound.

  • min_holes_size – lower bound for holes count.

  • max_holes_size – upper bound for holes count, None for countless.

  • min_hole_size – lower bound for hole size.

  • max_hole_size – upper bound for hole size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 5, 10
>>> min_holes_size, max_holes_size = 1, 4
>>> min_hole_size, max_hole_size = 3, 5
>>> polygons = planar.polygons(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)
>>> polygon = polygons.example()
>>> isinstance(polygon, tuple)
True
>>> len(polygon) == 2
True
>>> border, holes = polygon
>>> isinstance(border, list)
True
>>> isinstance(holes, list)
True
>>> all(isinstance(hole, list) for hole in holes)
True
>>> min_size <= len(border) <= max_size
True
>>> min_holes_size <= len(holes) <= max_holes_size
True
>>> all(min_hole_size <= len(hole) <= max_hole_size for hole in holes)
True
>>> all(isinstance(vertex, tuple) for vertex in border)
True
>>> all(isinstance(vertex, tuple) for hole in holes for vertex in hole)
True
>>> all(len(vertex) == 2 for vertex in border)
True
>>> all(len(vertex) == 2 for hole in holes for vertex in hole)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in border
...     for coordinate in vertex)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for hole in holes
...     for vertex in hole
...     for coordinate in vertex)
True
>>> all(all(min_coordinate <= coordinate <= max_coordinate
...         for coordinate in vertex)
...     for vertex in border)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for hole in holes
...     for vertex in hole
...     for coordinate in vertex)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 5, 10
>>> min_holes_size, max_holes_size = 1, 4
>>> min_hole_size, max_hole_size = 3, 5
>>> polygons = planar.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)
>>> polygon = polygons.example()
>>> isinstance(polygon, tuple)
True
>>> len(polygon) == 2
True
>>> border, holes = polygon
>>> isinstance(border, list)
True
>>> isinstance(holes, list)
True
>>> all(isinstance(hole, list) for hole in holes)
True
>>> min_size <= len(border) <= max_size
True
>>> min_holes_size <= len(holes) <= max_holes_size
True
>>> all(min_hole_size <= len(hole) <= max_hole_size for hole in holes)
True
>>> all(isinstance(vertex, tuple) for vertex in border)
True
>>> all(isinstance(vertex, tuple) for hole in holes for vertex in hole)
True
>>> all(len(vertex) == 2 for vertex in border)
True
>>> all(len(vertex) == 2 for hole in holes for vertex in hole)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for vertex in border
...     for coordinate in vertex)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for hole in holes
...     for vertex in hole
...     for coordinate in vertex)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for vertex_x, vertex_y in border)
True
>>> all(min_x_coordinate <= vertex_x <= max_x_coordinate
...     and min_y_coordinate <= vertex_y <= max_y_coordinate
...     for hole in holes
...     for vertex_x, vertex_y in hole)
True
hypothesis_geometry.planar.multipolygons(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_size: int = 0, max_size: Optional[int] = None, min_border_size: int = 3, max_border_size: Optional[int] = None, min_holes_size: int = 0, max_holes_size: Optional[int] = None, min_hole_size: int = 3, max_hole_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[List[Tuple[List[Tuple[numbers.Real, numbers.Real]], List[List[Tuple[numbers.Real, numbers.Real]]]]]][source]

Returns a strategy for multipolygons. Multipolygon is a possibly empty sequence of polygons with non-crossing and non-overlapping borders.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_size – lower bound for size.

  • max_size – upper bound for size, None for unbound.

  • min_border_size – lower bound for polygons’ border size.

  • max_border_size – upper bound for polygons’ border size, None for unbound.

  • min_holes_size – lower bound for polygons’ holes count.

  • max_holes_size – upper bound for polygons’ holes count, None for countless.

  • min_hole_size – lower bound for hole size.

  • max_hole_size – upper bound for polygons’ hole size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_size, max_size = 0, 5
>>> min_border_size, max_border_size = 5, 10
>>> min_holes_size, max_holes_size = 1, 4
>>> min_hole_size, max_hole_size = 3, 5
>>> multipolygons = planar.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)
>>> multipolygon = multipolygons.example()
>>> isinstance(multipolygon, list)
True
>>> min_size <= len(multipolygon) <= max_size
True
>>> all(isinstance(polygon, tuple) for polygon in multipolygon)
True
>>> all(len(polygon) == 2 for polygon in multipolygon)
True
>>> all(isinstance(border, list)
...     and isinstance(holes, list)
...     and all(isinstance(hole, list) for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(min_border_size <= len(border) <= max_border_size
...     and min_holes_size <= len(holes) <= max_holes_size
...     and all(min_hole_size <= len(hole) <= max_hole_size
...             for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(vertex, tuple) for vertex in border)
...     and all(isinstance(vertex, tuple)
...             for hole in holes
...             for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(len(vertex) == 2 for vertex in border)
...     and all(len(vertex) == 2 for hole in holes for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(coordinate, coordinates_type)
...         for vertex in border
...         for coordinate in vertex)
...     and all(isinstance(coordinate, coordinates_type)
...             for hole in holes
...             for vertex in hole
...             for coordinate in vertex)
...     for border, holes in multipolygon)
True
>>> all(all(all(min_coordinate <= coordinate <= max_coordinate
...             for coordinate in vertex)
...         for vertex in border)
...     and all(min_coordinate <= coordinate <= max_coordinate
...             for hole in holes
...             for vertex in hole
...             for coordinate in vertex)
...     for border, holes in multipolygon)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_size, max_size = 0, 5
>>> min_border_size, max_border_size = 5, 10
>>> min_holes_size, max_holes_size = 1, 4
>>> min_hole_size, max_hole_size = 3, 5
>>> multipolygons = planar.multipolygons(x_coordinates, y_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)
>>> multipolygon = multipolygons.example()
>>> isinstance(multipolygon, list)
True
>>> min_size <= len(multipolygon) <= max_size
True
>>> all(isinstance(polygon, tuple) for polygon in multipolygon)
True
>>> all(len(polygon) == 2 for polygon in multipolygon)
True
>>> all(isinstance(border, list)
...     and isinstance(holes, list)
...     and all(isinstance(hole, list) for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(min_border_size <= len(border) <= max_border_size
...     and min_holes_size <= len(holes) <= max_holes_size
...     and all(min_hole_size <= len(hole) <= max_hole_size
...             for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(vertex, tuple) for vertex in border)
...     and all(isinstance(vertex, tuple)
...             for hole in holes
...             for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(len(vertex) == 2 for vertex in border)
...     and all(len(vertex) == 2 for hole in holes for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(coordinate, coordinates_type)
...         for vertex in border
...         for coordinate in vertex)
...     and all(isinstance(coordinate, coordinates_type)
...             for hole in holes
...             for vertex in hole
...             for coordinate in vertex)
...     for border, holes in multipolygon)
True
>>> all(all(min_x_coordinate <= vertex_x <= max_x_coordinate
...         and min_y_coordinate <= vertex_y <= max_y_coordinate
...         for vertex_x, vertex_y in border)
...     and all(min_x_coordinate <= vertex_x <= max_x_coordinate
...             and min_y_coordinate <= vertex_y <= max_y_coordinate
...             for hole in holes
...             for vertex_x, vertex_y in hole)
...     for border, holes in multipolygon)
True
hypothesis_geometry.planar.mixes(x_coordinates: hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real], y_coordinates: Optional[hypothesis.strategies._internal.strategies.SearchStrategy[numbers.Real]] = None, *, min_multipoint_size: int = 0, max_multipoint_size: Optional[int] = None, min_multisegment_size: int = 0, max_multisegment_size: Optional[int] = None, min_multipolygon_size: int = 0, max_multipolygon_size: Optional[int] = None, min_multipolygon_border_size: int = 3, max_multipolygon_border_size: Optional[int] = None, min_multipolygon_holes_size: int = 0, max_multipolygon_holes_size: Optional[int] = None, min_multipolygon_hole_size: int = 3, max_multipolygon_hole_size: Optional[int] = None) → hypothesis.strategies._internal.strategies.SearchStrategy[Tuple[List[Tuple[numbers.Real, numbers.Real]], List[Tuple[Tuple[numbers.Real, numbers.Real], Tuple[numbers.Real, numbers.Real]]], List[Tuple[List[Tuple[numbers.Real, numbers.Real]], List[List[Tuple[numbers.Real, numbers.Real]]]]]]][source]

Returns a strategy for mixes. Mix is a triplet of disjoint multipoint, multisegment and multipolygon.

Parameters
  • x_coordinates – strategy for vertices’ x-coordinates.

  • y_coordinates – strategy for vertices’ y-coordinates, None for reusing x-coordinates strategy.

  • min_multipoint_size – lower bound for multipoint size.

  • max_multipoint_size – upper bound for multipoint size, None for unbound.

  • min_multisegment_size – lower bound for multisegment size.

  • max_multisegment_size – upper bound for multisegment size, None for unbound.

  • min_multipolygon_size – lower bound for multipolygon size.

  • max_multipolygon_size – upper bound for multipolygon size, None for unbound.

  • min_multipolygon_border_size – lower bound for polygons’ border size.

  • max_multipolygon_border_size – upper bound for polygons’ border size, None for unbound.

  • min_multipolygon_holes_size – lower bound for polygons’ holes count.

  • max_multipolygon_holes_size – upper bound for polygons’ holes count, None for countless.

  • min_multipolygon_hole_size – lower bound for hole size.

  • max_multipolygon_hole_size – upper bound for polygons’ hole size, None for unbound.

>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar

For same coordinates’ domain:

>>> min_coordinate, max_coordinate = -1., 1.
>>> coordinates_type = float
>>> coordinates = strategies.floats(min_coordinate, max_coordinate,
...                                 allow_infinity=False,
...                                 allow_nan=False)
>>> min_multipoint_size, max_multipoint_size = 2, 3
>>> min_multisegment_size, max_multisegment_size = 1, 4
>>> min_multipolygon_size, max_multipolygon_size = 0, 5
>>> min_multipolygon_border_size, max_multipolygon_border_size = 5, 10
>>> min_multipolygon_holes_size, max_multipolygon_holes_size = 1, 4
>>> min_multipolygon_hole_size, max_multipolygon_hole_size = 3, 5
>>> mixes = planar.mixes(
...         coordinates,
...         min_multipoint_size=min_multipoint_size,
...         max_multipoint_size=max_multipoint_size,
...         min_multisegment_size=min_multisegment_size,
...         max_multisegment_size=max_multisegment_size,
...         min_multipolygon_size=min_multipolygon_size,
...         max_multipolygon_size=max_multipolygon_size,
...         min_multipolygon_border_size=min_multipolygon_border_size,
...         max_multipolygon_border_size=max_multipolygon_border_size,
...         min_multipolygon_holes_size=min_multipolygon_holes_size,
...         max_multipolygon_holes_size=max_multipolygon_holes_size,
...         min_multipolygon_hole_size=min_multipolygon_hole_size,
...         max_multipolygon_hole_size=max_multipolygon_hole_size)
>>> mix = mixes.example()
>>> isinstance(mix, tuple)
True
>>> len(mix) == 3
True
>>> multipoint, multisegment, multipolygon = mix
>>> isinstance(multipoint, list)
True
>>> min_multipoint_size <= len(multipoint) <= max_multipoint_size
True
>>> all(isinstance(point, tuple) for point in multipoint)
True
>>> all(len(point) == 2 for point in multipoint)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for point in multipoint
...     for coordinate in point)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for point in multipoint
...     for coordinate in point)
True
>>> isinstance(multisegment, list)
True
>>> min_multisegment_size <= len(multisegment) <= max_multisegment_size
True
>>> all(isinstance(segment, tuple) for segment in multisegment)
True
>>> all(isinstance(endpoint, tuple)
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(len(segment) == 2 for segment in multisegment)
True
>>> all(len(endpoint) == 2
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for segment in multisegment
...     for endpoint in segment
...     for coordinate in endpoint)
True
>>> all(min_coordinate <= coordinate <= max_coordinate
...     for segment in multisegment
...     for endpoint in segment
...     for coordinate in endpoint)
True
>>> isinstance(multipolygon, list)
True
>>> min_multipolygon_size <= len(multipolygon) <= max_multipolygon_size
True
>>> all(isinstance(polygon, tuple) for polygon in multipolygon)
True
>>> all(len(polygon) == 2 for polygon in multipolygon)
True
>>> all(isinstance(border, list)
...     and isinstance(holes, list)
...     and all(isinstance(hole, list) for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(min_multipolygon_border_size
...     <= len(border)
...     <= max_multipolygon_border_size
...     and (min_multipolygon_holes_size
...          <= len(holes)
...          <= max_multipolygon_holes_size)
...     and all(min_multipolygon_hole_size
...             <= len(hole)
...             <= max_multipolygon_hole_size
...             for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(vertex, tuple) for vertex in border)
...     and all(isinstance(vertex, tuple)
...             for hole in holes
...             for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(len(vertex) == 2 for vertex in border)
...     and all(len(vertex) == 2 for hole in holes for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(coordinate, coordinates_type)
...         for vertex in border
...         for coordinate in vertex)
...     and all(isinstance(coordinate, coordinates_type)
...             for hole in holes
...             for vertex in hole
...             for coordinate in vertex)
...     for border, holes in multipolygon)
True
>>> all(all(all(min_coordinate <= coordinate <= max_coordinate
...             for coordinate in vertex)
...         for vertex in border)
...     and all(min_coordinate <= coordinate <= max_coordinate
...             for hole in holes
...             for vertex in hole
...             for coordinate in vertex)
...     for border, holes in multipolygon)
True

For different coordinates’ domains:

>>> min_x_coordinate, max_x_coordinate = -1., 1.
>>> min_y_coordinate, max_y_coordinate = 10., 100.
>>> coordinates_type = float
>>> x_coordinates = strategies.floats(min_x_coordinate, max_x_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> y_coordinates = strategies.floats(min_y_coordinate, max_y_coordinate,
...                                   allow_infinity=False,
...                                   allow_nan=False)
>>> min_multipoint_size, max_multipoint_size = 2, 3
>>> min_multisegment_size, max_multisegment_size = 1, 4
>>> min_multipolygon_size, max_multipolygon_size = 0, 5
>>> min_multipolygon_border_size, max_multipolygon_border_size = 5, 10
>>> min_multipolygon_holes_size, max_multipolygon_holes_size = 1, 4
>>> min_multipolygon_hole_size, max_multipolygon_hole_size = 3, 5
>>> mixes = planar.mixes(
...         x_coordinates, y_coordinates,
...         min_multipoint_size=min_multipoint_size,
...         max_multipoint_size=max_multipoint_size,
...         min_multisegment_size=min_multisegment_size,
...         max_multisegment_size=max_multisegment_size,
...         min_multipolygon_size=min_multipolygon_size,
...         max_multipolygon_size=max_multipolygon_size,
...         min_multipolygon_border_size=min_multipolygon_border_size,
...         max_multipolygon_border_size=max_multipolygon_border_size,
...         min_multipolygon_holes_size=min_multipolygon_holes_size,
...         max_multipolygon_holes_size=max_multipolygon_holes_size,
...         min_multipolygon_hole_size=min_multipolygon_hole_size,
...         max_multipolygon_hole_size=max_multipolygon_hole_size)
>>> mix = mixes.example()
>>> isinstance(mix, tuple)
True
>>> len(mix) == 3
True
>>> multipoint, multisegment, multipolygon = mix
>>> isinstance(multipoint, list)
True
>>> min_multipoint_size <= len(multipoint) <= max_multipoint_size
True
>>> all(isinstance(point, tuple) for point in multipoint)
True
>>> all(len(point) == 2 for point in multipoint)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for point in multipoint
...     for coordinate in point)
True
>>> all(min_x_coordinate <= point_x <= max_x_coordinate
...     and min_y_coordinate <= point_y <= max_y_coordinate
...     for point_x, point_y in multipoint)
True
>>> isinstance(multisegment, list)
True
>>> min_multisegment_size <= len(multisegment) <= max_multisegment_size
True
>>> all(isinstance(segment, tuple) for segment in multisegment)
True
>>> all(isinstance(endpoint, tuple)
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(len(segment) == 2 for segment in multisegment)
True
>>> all(len(endpoint) == 2
...     for segment in multisegment
...     for endpoint in segment)
True
>>> all(isinstance(coordinate, coordinates_type)
...     for segment in multisegment
...     for endpoint in segment
...     for coordinate in endpoint)
True
>>> all(min_x_coordinate <= endpoint_x <= max_x_coordinate
...     and min_y_coordinate <= endpoint_y <= max_y_coordinate
...     for segment in multisegment
...     for endpoint_x, endpoint_y in segment)
True
>>> isinstance(multipolygon, list)
True
>>> min_multipolygon_size <= len(multipolygon) <= max_multipolygon_size
True
>>> all(isinstance(polygon, tuple) for polygon in multipolygon)
True
>>> all(len(polygon) == 2 for polygon in multipolygon)
True
>>> all(isinstance(border, list)
...     and isinstance(holes, list)
...     and all(isinstance(hole, list) for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(min_multipolygon_border_size
...     <= len(border)
...     <= max_multipolygon_border_size
...     and (min_multipolygon_holes_size
...          <= len(holes)
...          <= max_multipolygon_holes_size)
...     and all(min_multipolygon_hole_size
...             <= len(hole)
...             <= max_multipolygon_hole_size
...             for hole in holes)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(vertex, tuple) for vertex in border)
...     and all(isinstance(vertex, tuple)
...             for hole in holes
...             for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(len(vertex) == 2 for vertex in border)
...     and all(len(vertex) == 2 for hole in holes for vertex in hole)
...     for border, holes in multipolygon)
True
>>> all(all(isinstance(coordinate, coordinates_type)
...         for vertex in border
...         for coordinate in vertex)
...     and all(isinstance(coordinate, coordinates_type)
...             for hole in holes
...             for vertex in hole
...             for coordinate in vertex)
...     for border, holes in multipolygon)
True
>>> all(all(min_x_coordinate <= vertex_x <= max_x_coordinate
...         and min_y_coordinate <= vertex_y <= max_y_coordinate
...         for vertex_x, vertex_y in border)
...     and all(min_x_coordinate <= vertex_x <= max_x_coordinate
...             and min_y_coordinate <= vertex_y <= max_y_coordinate
...             for hole in holes
...             for vertex_x, vertex_y in hole)
...     for border, holes in multipolygon)
True