Skip to content

Commit

Permalink
Add max_leaves parameter to geometry_collections function to determin…
Browse files Browse the repository at this point in the history
…e recursion depth
  • Loading branch information
cleder committed Dec 3, 2024
1 parent 8297404 commit 5412b39
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pygeoif/hypothesis/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ def geometry_collections( # noqa: PLR0913
max_points: int = 20,
min_interiors: int = 0,
max_interiors: int = 5,
max_leaves: int = 3,
srs: Optional[Srs] = None,
has_z: Optional[bool] = None,
) -> GeometryCollection:
Expand All @@ -557,17 +558,20 @@ def geometry_collections( # noqa: PLR0913
Args:
----
draw (st.DrawFn): The Hypothesis draw function.
min_geoms (int, optional): The minimum number of geometries in the collection.
max_geoms (int, optional): The maximum number of geometries in the collection.
max_points (int, optional): The maximum number of points in each geometry.
min_interiors (int, optional): The minimum number of interiors in each polygon.
max_interiors (int, optional): The maximum number of interiors in each polygon.
min_geoms (int): The minimum number of geometries in the collection.
max_geoms (int): The maximum number of geometries in the collection.
max_points (int): The maximum number of points in each geometry.
min_interiors (int): The minimum number of interiors in each polygon.
max_interiors (int): The maximum number of interiors in each polygon.
srs (Optional[Srs], optional): The spatial reference system of the geometries.
has_z (Optional[bool], optional): Whether the geometries have Z coordinates.
max_leaves (int): The maximum recursion depth of the collection.
Returns:
-------
GeometryCollection: A randomly generated GeometryCollection object.
GeometryCollection: A randomly generated GeometryCollection object, that may
contain any of the following geometries: Point, LineString, LinearRing,
Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection.
"""
if has_z is None:
Expand Down Expand Up @@ -612,7 +616,7 @@ def geometry_collections( # noqa: PLR0913
has_z=has_z,
),
lambda children: children,
max_leaves=3,
max_leaves=max_leaves,
),
),
min_size=min_geoms,
Expand Down

0 comments on commit 5412b39

Please sign in to comment.