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.empty_geometries(context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Empty][source]

Returns a strategy for empty geometries.

Parameters

context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Empty = context.empty_cls
>>> empty_geometries = planar.empty_geometries()
>>> empty = empty_geometries.example()
>>> isinstance(empty, Empty)
True
hypothesis_geometry.planar.points(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Point[ground.core.hints.Scalar]][source]

Returns a strategy for points.

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

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

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Point = context.point_cls

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, Point)
True
>>> (isinstance(point.x, coordinates_type)
...  and isinstance(point.y, coordinates_type))
True
>>> (min_coordinate <= point.x <= max_coordinate
...  and min_coordinate <= point.y <= max_coordinate)
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, Point)
True
>>> (isinstance(point.x, coordinates_type)
...  and isinstance(point.y, coordinates_type))
True
>>> (min_x_coordinate <= point.x <= max_x_coordinate
...  and min_y_coordinate <= point.y <= max_y_coordinate)
True
hypothesis_geometry.planar.multipoints(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = 1, max_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Multipoint[ground.core.hints.Scalar]][source]

Returns a strategy for multipoints.

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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Multipoint = context.multipoint_cls

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, Multipoint)
True
>>> min_size <= len(multipoint.points) <= max_size
True
>>> all(isinstance(point.x, coordinates_type)
...     and isinstance(point.y, coordinates_type)
...     for point in multipoint.points)
True
>>> all(min_coordinate <= point.x <= max_coordinate
...     and min_coordinate <= point.y <= max_coordinate
...     for point in multipoint.points)
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, Multipoint)
True
>>> min_size <= len(multipoint.points) <= max_size
True
>>> all(isinstance(point.x, coordinates_type)
...     and isinstance(point.y, coordinates_type)
...     for point in multipoint.points)
True
>>> all(min_x_coordinate <= point.x <= max_x_coordinate
...     and min_y_coordinate <= point.y <= max_y_coordinate
...     for point in multipoint.points)
True
hypothesis_geometry.planar.segments(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Segment[ground.core.hints.Scalar]][source]

Returns a strategy for segments.

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

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

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Segment = context.segment_cls

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, Segment)
True
>>> (isinstance(segment.start.x, coordinates_type)
...  and isinstance(segment.start.y, coordinates_type)
...  and isinstance(segment.end.x, coordinates_type)
...  and isinstance(segment.end.y, coordinates_type))
True
>>> (min_coordinate <= segment.start.x <= max_coordinate
...  and min_coordinate <= segment.start.y <= max_coordinate
...  and min_coordinate <= segment.end.x <= max_coordinate
...  and min_coordinate <= segment.end.y <= max_coordinate)
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, Segment)
True
>>> (isinstance(segment.start.x, coordinates_type)
...  and isinstance(segment.start.y, coordinates_type)
...  and isinstance(segment.end.x, coordinates_type)
...  and isinstance(segment.end.y, coordinates_type))
True
>>> (min_x_coordinate <= segment.start.x <= max_x_coordinate
...  and min_y_coordinate <= segment.start.y <= max_y_coordinate
...  and min_x_coordinate <= segment.end.x <= max_x_coordinate
...  and min_y_coordinate <= segment.end.y <= max_y_coordinate)
True
hypothesis_geometry.planar.multisegments(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = 2, max_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Multisegment[ground.core.hints.Scalar]][source]

Returns a strategy for multisegments.

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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Multisegment = context.multisegment_cls

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, Multisegment)
True
>>> min_size <= len(multisegment.segments) <= max_size
True
>>> all(isinstance(segment.start.x, coordinates_type)
...     and isinstance(segment.start.y, coordinates_type)
...     and isinstance(segment.start.x, coordinates_type)
...     and isinstance(segment.start.y, coordinates_type)
...     for segment in multisegment.segments)
True
>>> all(min_coordinate <= segment.start.x <= max_coordinate
...     and min_coordinate <= segment.start.y <= max_coordinate
...     and min_coordinate <= segment.end.x <= max_coordinate
...     and min_coordinate <= segment.end.y <= max_coordinate
...     for segment in multisegment.segments)
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, Multisegment)
True
>>> min_size <= len(multisegment.segments) <= max_size
True
>>> all(isinstance(segment.start.x, coordinates_type)
...     and isinstance(segment.start.y, coordinates_type)
...     and isinstance(segment.start.x, coordinates_type)
...     and isinstance(segment.start.y, coordinates_type)
...     for segment in multisegment.segments)
True
>>> all(min_x_coordinate <= segment.start.x <= max_x_coordinate
...     and min_y_coordinate <= segment.start.y <= max_y_coordinate
...     and min_x_coordinate <= segment.end.x <= max_x_coordinate
...     and min_y_coordinate <= segment.end.y <= max_y_coordinate
...     for segment in multisegment.segments)
True
hypothesis_geometry.planar.contours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = <MinContourSize.CONVEX: 3>, max_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Contour[ground.core.hints.Scalar]][source]

Returns a strategy for 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 contour size.

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

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in contour.vertices)
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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in contour.vertices)
True
hypothesis_geometry.planar.convex_contours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = <MinContourSize.CONVEX: 3>, max_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Contour[ground.core.hints.Scalar]][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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in contour.vertices)
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.convex_contours(x_coordinates, y_coordinates,
...                                   min_size=min_size,
...                                   max_size=max_size)
>>> contour = contours.example()
>>> isinstance(contour, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in contour.vertices)
True
hypothesis_geometry.planar.concave_contours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = <MinContourSize.CONCAVE: 4>, max_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Contour[ground.core.hints.Scalar]][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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in contour.vertices)
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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in contour.vertices)
True
hypothesis_geometry.planar.triangular_contours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Contour[ground.core.hints.Scalar]][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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour)
True
>>> len(contour.vertices) == 3
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in contour.vertices)
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, Contour)
True
>>> len(contour.vertices) == 3
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in contour.vertices)
True
hypothesis_geometry.planar.rectangular_contours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Contour[ground.core.hints.Scalar]][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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour)
True
>>> len(contour.vertices) == 4
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in contour.vertices)
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, Contour)
True
>>> len(contour.vertices) == 4
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in contour.vertices)
True
hypothesis_geometry.planar.boxes(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Box[ground.core.hints.Scalar]][source]

Returns a strategy for boxes.

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

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

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Box = context.box_cls

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)
>>> boxes = planar.boxes(coordinates)
>>> box = boxes.example()
>>> isinstance(box, Box)
True
>>> (isinstance(box.min_x, coordinates_type)
...  and isinstance(box.max_x, coordinates_type)
...  and isinstance(box.min_y, coordinates_type)
...  and isinstance(box.max_y, coordinates_type))
True
>>> (min_coordinate <= box.min_x <= max_coordinate
...  and min_coordinate <= box.max_x <= max_coordinate
...  and min_coordinate <= box.min_y <= max_coordinate
...  and min_coordinate <= box.max_y <= max_coordinate)
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)
>>> boxes = planar.boxes(x_coordinates, y_coordinates)
>>> box = boxes.example()
>>> isinstance(box, Box)
True
>>> (isinstance(box.min_x, coordinates_type)
...  and isinstance(box.max_x, coordinates_type)
...  and isinstance(box.min_y, coordinates_type)
...  and isinstance(box.max_y, coordinates_type))
True
>>> (min_x_coordinate <= box.min_x <= max_x_coordinate
...  and min_x_coordinate <= box.max_x <= max_x_coordinate)
True
>>> (min_y_coordinate <= box.min_y <= max_y_coordinate
...  and min_y_coordinate <= box.max_y <= max_y_coordinate)
True
hypothesis_geometry.planar.star_contours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = <MinContourSize.CONVEX: 3>, max_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Contour[ground.core.hints.Scalar]][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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in contour.vertices)
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, Contour)
True
>>> min_size <= len(contour.vertices) <= max_size
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in contour.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in contour.vertices)
True
hypothesis_geometry.planar.multicontours(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = 2, max_size: Optional[int] = None, min_contour_size: int = <MinContourSize.CONVEX: 3>, max_contour_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[Sequence[ground.hints.Contour[ground.core.hints.Scalar]]][source]

Returns a strategy for multicontours. Multicontour is a sequence of two or more 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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls

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, Contour) for contour in multicontour)
True
>>> min_size <= len(multicontour) <= max_size
True
>>> all(min_contour_size <= len(contour.vertices) <= max_contour_size
...     for contour in multicontour)
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for contour in multicontour
...     for vertex in contour.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for contour in multicontour
...     for vertex in contour.vertices)
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, Contour) for contour in multicontour)
True
>>> min_size <= len(multicontour) <= max_size
True
>>> all(min_contour_size <= len(contour.vertices) <= max_contour_size
...     for contour in multicontour)
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for contour in multicontour
...     for vertex in contour.vertices)
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 in contour.vertices)
True
hypothesis_geometry.planar.polygons(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = <MinContourSize.CONVEX: 3>, max_size: Optional[int] = None, min_holes_size: int = 0, max_holes_size: Optional[int] = None, min_hole_size: int = <MinContourSize.CONVEX: 3>, max_hole_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Polygon[ground.core.hints.Scalar]][source]

Returns a strategy for polygons.

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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Polygon = context.polygon_cls

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, Polygon)
True
>>> min_size <= len(polygon.border.vertices) <= max_size
True
>>> min_holes_size <= len(polygon.holes) <= max_holes_size
True
>>> all(min_hole_size <= len(hole.vertices) <= max_hole_size
...     for hole in polygon.holes)
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in polygon.border.vertices)
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for hole in polygon.holes
...     for vertex in hole.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for vertex in polygon.border.vertices)
True
>>> all(min_coordinate <= vertex.x <= max_coordinate
...     and min_coordinate <= vertex.y <= max_coordinate
...     for hole in polygon.holes
...     for vertex in hole.vertices)
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, Polygon)
True
>>> min_size <= len(polygon.border.vertices) <= max_size
True
>>> min_holes_size <= len(polygon.holes) <= max_holes_size
True
>>> all(min_hole_size <= len(hole.vertices) <= max_hole_size
...     for hole in polygon.holes)
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for vertex in polygon.border.vertices)
True
>>> all(isinstance(vertex.x, coordinates_type)
...     and isinstance(vertex.y, coordinates_type)
...     for hole in polygon.holes
...     for vertex in hole.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for vertex in polygon.border.vertices)
True
>>> all(min_x_coordinate <= vertex.x <= max_x_coordinate
...     and min_y_coordinate <= vertex.y <= max_y_coordinate
...     for hole in polygon.holes
...     for vertex in hole.vertices)
True
hypothesis_geometry.planar.multipolygons(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_size: int = 2, max_size: Optional[int] = None, min_border_size: int = <MinContourSize.CONVEX: 3>, max_border_size: Optional[int] = None, min_holes_size: int = 0, max_holes_size: Optional[int] = None, min_hole_size: int = <MinContourSize.CONVEX: 3>, max_hole_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Multipolygon[ground.core.hints.Scalar]][source]

Returns a strategy for multipolygons.

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.

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Multipolygon = context.multipolygon_cls

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, Multipolygon)
True
>>> min_size <= len(multipolygon.polygons) <= max_size
True
>>> all(min_border_size <= len(polygon.border.vertices) <= max_border_size
...     and min_holes_size <= len(polygon.holes) <= max_holes_size
...     and all(min_hole_size <= len(hole.vertices) <= max_hole_size
...             for hole in polygon.holes)
...     for polygon in multipolygon.polygons)
True
>>> all(all(isinstance(vertex.x, coordinates_type)
...         and isinstance(vertex.y, coordinates_type)
...         for vertex in polygon.border.vertices)
...     and all(isinstance(vertex.x, coordinates_type)
...             and isinstance(vertex.y, coordinates_type)
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in multipolygon.polygons)
True
>>> all(all(min_coordinate <= vertex.x <= max_coordinate
...         and min_coordinate <= vertex.y <= max_coordinate
...         for vertex in polygon.border.vertices)
...     and all(min_coordinate <= vertex.x <= max_coordinate
...             and min_coordinate <= vertex.y <= max_coordinate
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in multipolygon.polygons)
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, Multipolygon)
True
>>> min_size <= len(multipolygon.polygons) <= max_size
True
>>> all(min_border_size <= len(polygon.border.vertices) <= max_border_size
...     and min_holes_size <= len(polygon.holes) <= max_holes_size
...     and all(min_hole_size <= len(hole.vertices) <= max_hole_size
...             for hole in polygon.holes)
...     for polygon in multipolygon.polygons)
True
>>> all(all(isinstance(vertex.x, coordinates_type)
...         and isinstance(vertex.y, coordinates_type)
...         for vertex in polygon.border.vertices)
...     and all(isinstance(vertex.x, coordinates_type)
...             and isinstance(vertex.y, coordinates_type)
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in multipolygon.polygons)
True
>>> all(all(min_x_coordinate <= vertex.x <= max_x_coordinate
...         and min_y_coordinate <= vertex.y <= max_y_coordinate
...         for vertex in polygon.border.vertices)
...     and all(min_x_coordinate <= vertex.x <= max_x_coordinate
...             and min_y_coordinate <= vertex.y <= max_y_coordinate
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in multipolygon.polygons)
True
hypothesis_geometry.planar.mixes(x_coordinates: hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar], y_coordinates: Optional[hypothesis.strategies.SearchStrategy[ground.core.hints.Scalar]] = None, *, min_points_size: int = 0, max_points_size: Optional[int] = None, min_segments_size: int = 0, max_segments_size: Optional[int] = None, min_polygons_size: int = 0, max_polygons_size: Optional[int] = None, min_polygon_border_size: int = <MinContourSize.CONVEX: 3>, max_polygon_border_size: Optional[int] = None, min_polygon_holes_size: int = 0, max_polygon_holes_size: Optional[int] = None, min_polygon_hole_size: int = <MinContourSize.CONVEX: 3>, max_polygon_hole_size: Optional[int] = None, context: Optional[ground.base.Context] = None)hypothesis.strategies.SearchStrategy[ground.hints.Mix[ground.core.hints.Scalar]][source]

Returns a strategy for mixes.

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

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

  • min_points_size – lower bound for discrete component points size.

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

  • min_segments_size – lower bound for linear component segments size.

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

  • min_polygons_size – lower bound for shaped component polygons size.

  • max_polygons_size – upper bound for shaped component polygons size, None for unbound.

  • min_polygon_border_size – lower bound for polygons’ border size.

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

  • min_polygon_holes_size – lower bound for polygons’ holes count.

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

  • min_polygon_hole_size – lower bound for polygons’ hole size.

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

  • context – strategy context.

>>> from ground.base import get_context
>>> from hypothesis import strategies
>>> from hypothesis_geometry import planar
>>> context = get_context()
>>> Contour = context.contour_cls
>>> Empty = context.empty_cls
>>> Mix = context.mix_cls
>>> Multipoint = context.multipoint_cls
>>> Multipolygon = context.multipolygon_cls
>>> Multisegment = context.multisegment_cls
>>> Polygon = context.polygon_cls
>>> Segment = context.segment_cls

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_points_size, max_points_size = 2, 3
>>> min_segments_size, max_segments_size = 1, 4
>>> min_polygons_size, max_polygons_size = 0, 5
>>> min_polygon_border_size, max_polygon_border_size = 5, 10
>>> min_polygon_holes_size, max_polygon_holes_size = 1, 4
>>> min_polygon_hole_size, max_polygon_hole_size = 3, 5
>>> mixes = planar.mixes(coordinates,
...                      min_points_size=min_points_size,
...                      max_points_size=max_points_size,
...                      min_segments_size=min_segments_size,
...                      max_segments_size=max_segments_size,
...                      min_polygons_size=min_polygons_size,
...                      max_polygons_size=max_polygons_size,
...                      min_polygon_border_size=min_polygon_border_size,
...                      max_polygon_border_size=max_polygon_border_size,
...                      min_polygon_holes_size=min_polygon_holes_size,
...                      max_polygon_holes_size=max_polygon_holes_size,
...                      min_polygon_hole_size=min_polygon_hole_size,
...                      max_polygon_hole_size=max_polygon_hole_size)
>>> mix = mixes.example()
>>> isinstance(mix, Mix)
True
>>> isinstance(mix.discrete, (Empty, Multipoint))
True
>>> points = [] if isinstance(mix.discrete, Empty) else mix.discrete.points
>>> min_points_size <= len(points) <= max_points_size
True
>>> all(isinstance(point.x, coordinates_type)
...     and isinstance(point.y, coordinates_type)
...     for point in points)
True
>>> all(min_coordinate <= point.x <= max_coordinate
...     and min_coordinate <= point.y <= max_coordinate
...     for point in points)
True
>>> isinstance(mix.linear, (Empty, Segment, Contour, Multisegment))
True
>>> segments = ([]
...             if isinstance(mix.linear, Empty)
...             else ([mix.linear]
...                   if isinstance(mix.linear, Segment)
...                   else (mix.linear.segments
...                         if isinstance(mix.linear, Multisegment)
...                         else context.contour_segments(mix.linear))))
>>> min_segments_size <= len(segments) <= max_segments_size
True
>>> all(isinstance(segment.start.x, coordinates_type)
...     and isinstance(segment.start.y, coordinates_type)
...     and isinstance(segment.end.x, coordinates_type)
...     and isinstance(segment.end.y, coordinates_type)
...     for segment in segments)
True
>>> all(min_coordinate <= segment.start.x <= max_coordinate
...     and min_coordinate <= segment.start.y <= max_coordinate
...     and min_coordinate <= segment.end.x <= max_coordinate
...     and min_coordinate <= segment.end.y <= max_coordinate
...     for segment in segments)
True
>>> isinstance(mix.shaped, (Empty, Polygon, Multipolygon))
True
>>> polygons = ([]
...             if isinstance(mix.shaped, Empty)
...             else ([mix.shaped]
...                   if isinstance(mix.shaped, Polygon)
...                   else mix.shaped.polygons))
>>> min_polygons_size <= len(polygons) <= max_polygons_size
True
>>> all(min_polygon_border_size
...     <= len(polygon.border.vertices)
...     <= max_polygon_border_size
...     and (min_polygon_holes_size
...          <= len(polygon.holes)
...          <= max_polygon_holes_size)
...     and all(min_polygon_hole_size
...             <= len(hole.vertices)
...             <= max_polygon_hole_size
...             for hole in polygon.holes)
...     for polygon in polygons)
True
>>> all(all(isinstance(vertex.x, coordinates_type)
...         and isinstance(vertex.y, coordinates_type)
...         for vertex in polygon.border.vertices)
...     and all(isinstance(vertex.x, coordinates_type)
...             and isinstance(vertex.y, coordinates_type)
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in polygons)
True
>>> all(all(min_coordinate <= vertex.x <= max_coordinate
...         and min_coordinate <= vertex.y <= max_coordinate
...         for vertex in polygon.border.vertices)
...     and all(min_coordinate <= vertex.x <= max_coordinate
...             and min_coordinate <= vertex.y <= max_coordinate
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in polygons)
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_points_size, max_points_size = 2, 3
>>> min_segments_size, max_segments_size = 1, 4
>>> min_polygons_size, max_polygons_size = 0, 5
>>> min_polygon_border_size, max_polygon_border_size = 5, 10
>>> min_polygon_holes_size, max_polygon_holes_size = 1, 4
>>> min_polygon_hole_size, max_polygon_hole_size = 3, 5
>>> mixes = planar.mixes(x_coordinates, y_coordinates,
...                      min_points_size=min_points_size,
...                      max_points_size=max_points_size,
...                      min_segments_size=min_segments_size,
...                      max_segments_size=max_segments_size,
...                      min_polygons_size=min_polygons_size,
...                      max_polygons_size=max_polygons_size,
...                      min_polygon_border_size=min_polygon_border_size,
...                      max_polygon_border_size=max_polygon_border_size,
...                      min_polygon_holes_size=min_polygon_holes_size,
...                      max_polygon_holes_size=max_polygon_holes_size,
...                      min_polygon_hole_size=min_polygon_hole_size,
...                      max_polygon_hole_size=max_polygon_hole_size)
>>> mix = mixes.example()
>>> isinstance(mix, Mix)
True
>>> isinstance(mix.discrete, (Empty, Multipoint))
True
>>> points = [] if isinstance(mix.discrete, Empty) else mix.discrete.points
>>> min_points_size <= len(points) <= max_points_size
True
>>> all(isinstance(point.x, coordinates_type)
...     and isinstance(point.y, coordinates_type)
...     for point in points)
True
>>> all(min_x_coordinate <= point.x <= max_x_coordinate
...     and min_y_coordinate <= point.y <= max_y_coordinate
...     for point in points)
True
>>> isinstance(mix.linear, (Empty, Segment, Contour, Multisegment))
True
>>> segments = ([]
...             if isinstance(mix.linear, Empty)
...             else ([mix.linear]
...                   if isinstance(mix.linear, Segment)
...                   else (mix.linear.segments
...                         if isinstance(mix.linear, Multisegment)
...                         else context.contour_segments(mix.linear))))
>>> min_segments_size <= len(segments) <= max_segments_size
True
>>> all(isinstance(segment.start.x, coordinates_type)
...     and isinstance(segment.start.y, coordinates_type)
...     and isinstance(segment.end.x, coordinates_type)
...     and isinstance(segment.end.y, coordinates_type)
...     for segment in segments)
True
>>> all(min_x_coordinate <= segment.start.x <= max_x_coordinate
...     and min_y_coordinate <= segment.start.y <= max_y_coordinate
...     and min_x_coordinate <= segment.end.x <= max_x_coordinate
...     and min_y_coordinate <= segment.end.y <= max_y_coordinate
...     for segment in segments)
True
>>> isinstance(mix.shaped, (Empty, Polygon, Multipolygon))
True
>>> polygons = ([]
...             if isinstance(mix.shaped, Empty)
...             else ([mix.shaped]
...                   if isinstance(mix.shaped, Polygon)
...                   else mix.shaped.polygons))
>>> min_polygons_size <= len(polygons) <= max_polygons_size
True
>>> all(min_polygon_border_size
...     <= len(polygon.border.vertices)
...     <= max_polygon_border_size
...     and (min_polygon_holes_size
...          <= len(polygon.holes)
...          <= max_polygon_holes_size)
...     and all(min_polygon_hole_size
...             <= len(hole.vertices)
...             <= max_polygon_hole_size
...             for hole in polygon.holes)
...     for polygon in polygons)
True
>>> all(all(isinstance(vertex.x, coordinates_type)
...         and isinstance(vertex.y, coordinates_type)
...         for vertex in polygon.border.vertices)
...     and all(isinstance(vertex.x, coordinates_type)
...             and isinstance(vertex.y, coordinates_type)
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in polygons)
True
>>> all(all(min_x_coordinate <= vertex.x <= max_x_coordinate
...         and min_y_coordinate <= vertex.y <= max_y_coordinate
...         for vertex in polygon.border.vertices)
...     and all(min_x_coordinate <= vertex.x <= max_x_coordinate
...             and min_y_coordinate <= vertex.y <= max_y_coordinate
...             for hole in polygon.holes
...             for vertex in hole.vertices)
...     for polygon in polygons)
True