Skip to content

Commit 4856d64

Browse files
authored
Improve docstring of data_kind() to include xarray grid (#588)
Improve the docstrings of data_kind() and add one more doctest.
1 parent c1a074b commit 4856d64

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pygmt/helpers/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def data_kind(data, x=None, y=None, z=None):
2020
Possible types:
2121
2222
* a file name provided as 'data'
23+
* an xarray.DataArray provided as 'data'
2324
* a matrix provided as 'data'
2425
* 1D arrays x and y (and z, optionally)
2526
@@ -28,8 +29,8 @@ def data_kind(data, x=None, y=None, z=None):
2829
2930
Parameters
3031
----------
31-
data : str, 2d array, or None
32-
Data file name or numpy array.
32+
data : str, xarray.DataArray, 2d array, or None
33+
Data file name, xarray.DataArray or numpy array.
3334
x/y : 1d arrays or None
3435
x and y columns as numpy arrays.
3536
z : 1d array or None
@@ -39,18 +40,21 @@ def data_kind(data, x=None, y=None, z=None):
3940
Returns
4041
-------
4142
kind : str
42-
One of: ``'file'``, ``'matrix'``, ``'vectors'``.
43+
One of: ``'file'``, ``'grid'``, ``'matrix'``, ``'vectors'``.
4344
4445
Examples
4546
--------
4647
4748
>>> import numpy as np
49+
>>> import xarray as xr
4850
>>> data_kind(data=None, x=np.array([1, 2, 3]), y=np.array([4, 5, 6]))
4951
'vectors'
5052
>>> data_kind(data=np.arange(10).reshape((5, 2)), x=None, y=None)
5153
'matrix'
5254
>>> data_kind(data='my-data-file.txt', x=None, y=None)
5355
'file'
56+
>>> data_kind(data=xr.DataArray(np.random.rand(4, 3)))
57+
'grid'
5458
5559
"""
5660
if data is None and x is None and y is None:

0 commit comments

Comments
 (0)