Skip to content

Commit

Permalink
DOC: Add kwargs where necessary and document it (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervdw committed Apr 2, 2021
1 parent 82eb14e commit 8afbc60
Show file tree
Hide file tree
Showing 8 changed files with 350 additions and 46 deletions.
57 changes: 57 additions & 0 deletions pygeos/constructive.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def boundary(geometry, **kwargs):
----------
geometry : Geometry or array_like
This function will return None for geometrycollections.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -115,6 +118,9 @@ def buffer(
buffered vertex by more than this limit.
single_sided : bool
Only buffer at one side of the geometry.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -204,6 +210,9 @@ def offset_curve(
mitre_limit : float
Crops of 'mitre'-style joins if the point is displaced from the
buffered vertex by more than this limit.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -243,6 +252,9 @@ def centroid(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -282,6 +294,9 @@ def clip_by_rect(geometry, xmin, ymin, xmax, ymax, **kwargs):
Maximum x value of the rectangle
ymax : float
Maximum y value of the rectangle
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand All @@ -308,6 +323,9 @@ def convex_hull(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -336,6 +354,9 @@ def delaunay_triangles(geometry, tolerance=0.0, only_edges=False, **kwargs):
only_edges : bool or array_like
If set to True, the triangulation will return a collection of
linestrings instead of polygons.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -363,6 +384,9 @@ def envelope(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand All @@ -388,6 +412,9 @@ def extract_unique_points(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -417,6 +444,9 @@ def build_area(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand All @@ -436,6 +466,9 @@ def make_valid(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand All @@ -456,6 +489,9 @@ def normalize(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand All @@ -473,6 +509,9 @@ def point_on_surface(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -514,6 +553,9 @@ def polygonize(geometries, **kwargs):
Axis along which the geometries are polygonized.
The default is to perform a reduction over the last dimension
of the input array. A 1D array results in a scalar geometry.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Returns
-------
Expand Down Expand Up @@ -549,6 +591,9 @@ def reverse(geometry, **kwargs):
Parameters
----------
geometry : Geometry or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
See also
--------
Expand Down Expand Up @@ -585,6 +630,9 @@ def segmentize(geometry, tolerance, **kwargs):
tolerance : float or array_like
Additional vertices will be added so that all line segments are no
greater than this value. Must be greater than 0.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -613,6 +661,9 @@ def simplify(geometry, tolerance, preserve_topology=False, **kwargs):
smaller the number of vertices in the resulting geometry.
preserve_topology : bool
If set to True, the operation will avoid creating invalid geometries.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -646,6 +697,9 @@ def snap(geometry, reference, tolerance, **kwargs):
geometry : Geometry or array_like
reference : Geometry or array_like
tolerance : float or array_like
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down Expand Up @@ -684,6 +738,9 @@ def voronoi_polygons(
only_edges : bool or array_like
If set to True, the triangulation will return a collection of
linestrings instead of polygons.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand Down
53 changes: 45 additions & 8 deletions pygeos/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def points(coords, y=None, z=None, indices=None, **kwargs):
provided, the coords should be 2D with shape (N, 2) or (N, 3) and
indices should be 1D with shape (N,). Missing indices will give None
values in the output array.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
coords = _xyz_to_coords(coords, y, z)
if indices is None:
Expand Down Expand Up @@ -75,6 +79,10 @@ def linestrings(coords, y=None, z=None, indices=None, **kwargs):
provided, the coords should be 2D with shape (N, 2) or (N, 3) and
indices should be 1D with shape (N,). Missing indices will give None
values in the output array.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
coords = _xyz_to_coords(coords, y, z)
if indices is None:
Expand Down Expand Up @@ -104,6 +112,10 @@ def linearrings(coords, y=None, z=None, indices=None, **kwargs):
provided, the coords should be 2D with shape (N, 2) or (N, 3) and
indices should be 1D with shape (N,). Missing indices will give None
values in the output array.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
coords = _xyz_to_coords(coords, y, z)
if indices is None:
Expand Down Expand Up @@ -151,6 +163,9 @@ def box(xmin, ymin, xmax, ymax, ccw=True, **kwargs):
from bottom right coordinate (xmax, ymin).
If False, box will be created in clockwise direction starting from
bottom left coordinate (xmin, ymin).
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Examples
--------
Expand All @@ -163,7 +178,7 @@ def box(xmin, ymin, xmax, ymax, ccw=True, **kwargs):
return lib.box(xmin, ymin, xmax, ymax, ccw, **kwargs)


def multipoints(geometries, indices=None):
def multipoints(geometries, indices=None, **kwargs):
"""Create multipoints from arrays of points
Parameters
Expand All @@ -174,6 +189,10 @@ def multipoints(geometries, indices=None):
Indices into the target array where input geometries belong. If
provided, both geometries and indices should be 1D and have matching
sizes.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
typ = GeometryType.MULTIPOINT
geometries = np.asarray(geometries)
Expand All @@ -182,12 +201,12 @@ def multipoints(geometries, indices=None):
):
geometries = points(geometries)
if indices is None:
return lib.create_collection(geometries, typ)
return lib.create_collection(geometries, typ, **kwargs)
else:
return collections_1d(geometries, indices, typ)


def multilinestrings(geometries, indices=None):
def multilinestrings(geometries, indices=None, **kwargs):
"""Create multilinestrings from arrays of linestrings
Parameters
Expand All @@ -198,6 +217,10 @@ def multilinestrings(geometries, indices=None):
Indices into the target array where input geometries belong. If
provided, both geometries and indices should be 1D and have matching
sizes.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
typ = GeometryType.MULTILINESTRING
geometries = np.asarray(geometries)
Expand All @@ -207,12 +230,12 @@ def multilinestrings(geometries, indices=None):
geometries = linestrings(geometries)

if indices is None:
return lib.create_collection(geometries, typ)
return lib.create_collection(geometries, typ, **kwargs)
else:
return collections_1d(geometries, indices, typ)


def multipolygons(geometries, indices=None):
def multipolygons(geometries, indices=None, **kwargs):
"""Create multipolygons from arrays of polygons
Parameters
Expand All @@ -223,6 +246,10 @@ def multipolygons(geometries, indices=None):
Indices into the target array where input geometries belong. If
provided, both geometries and indices should be 1D and have matching
sizes.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
typ = GeometryType.MULTIPOLYGON
geometries = np.asarray(geometries)
Expand All @@ -231,12 +258,12 @@ def multipolygons(geometries, indices=None):
):
geometries = polygons(geometries)
if indices is None:
return lib.create_collection(geometries, typ)
return lib.create_collection(geometries, typ, **kwargs)
else:
return collections_1d(geometries, indices, typ)


def geometrycollections(geometries, indices=None):
def geometrycollections(geometries, indices=None, **kwargs):
"""Create geometrycollections from arrays of geometries
Parameters
Expand All @@ -247,10 +274,14 @@ def geometrycollections(geometries, indices=None):
Indices into the target array where input geometries belong. If
provided, both geometries and indices should be 1D and have matching
sizes.
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
Ignored if ``indices`` is provided.
"""
typ = GeometryType.GEOMETRYCOLLECTION
if indices is None:
return lib.create_collection(geometries, typ)
return lib.create_collection(geometries, typ, **kwargs)
else:
return collections_1d(geometries, indices, typ)

Expand All @@ -273,6 +304,9 @@ def prepare(geometry, **kwargs):
----------
geometry : Geometry or array_like
Geometries are changed inplace
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
See also
--------
Expand All @@ -293,6 +327,9 @@ def destroy_prepared(geometry, **kwargs):
----------
geometry : Geometry or array_like
Geometries are changed inplace
**kwargs
For other keyword-only arguments, see the
`NumPy ufunc docs <https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs>`_.
See also
--------
Expand Down

0 comments on commit 8afbc60

Please sign in to comment.