Skip to content

Commit

Permalink
Improve docstrings of data_kind()
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Sep 6, 2020
1 parent 526e38b commit 91858e1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def data_kind(data, x=None, y=None, z=None):
Possible types:
* a file name provided as 'data'
* an xarray.DataArray provided as 'data'
* a matrix provided as 'data'
* 1D arrays x and y (and z, optionally)
Expand All @@ -28,8 +29,8 @@ def data_kind(data, x=None, y=None, z=None):
Parameters
----------
data : str, 2d array, or None
Data file name or numpy array.
data : str, xarray.DataArray, 2d array, or None
Data file name, xarray.DataArray or numpy array.
x/y : 1d arrays or None
x and y columns as numpy arrays.
z : 1d array or None
Expand All @@ -39,18 +40,21 @@ def data_kind(data, x=None, y=None, z=None):
Returns
-------
kind : str
One of: ``'file'``, ``'matrix'``, ``'vectors'``.
One of: ``'file'``, ``'grid'``, ``'matrix'``, ``'vectors'``.
Examples
--------
>>> import numpy as np
>>> import xarray as xr
>>> data_kind(data=None, x=np.array([1, 2, 3]), y=np.array([4, 5, 6]))
'vectors'
>>> data_kind(data=np.arange(10).reshape((5, 2)), x=None, y=None)
'matrix'
>>> data_kind(data='my-data-file.txt', x=None, y=None)
'file'
>>> data_kind(data=xr.DataArray(np.random.rand(4, 3)))
'grid'
"""
if data is None and x is None and y is None:
Expand Down

0 comments on commit 91858e1

Please sign in to comment.