Skip to content

Commit ebd2264

Browse files
committed
Move check_kind to be the first parameter
1 parent eca7427 commit ebd2264

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

pygmt/clib/session.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def virtualfile_from_grid(self, grid):
13601360
with self.open_virtual_file(*args) as vfile:
13611361
yield vfile
13621362

1363-
def virtualfile_from_data(self, data, x=None, y=None, z=None, check_kind=None):
1363+
def virtualfile_from_data(self, check_kind=None, data=None, x=None, y=None, z=None):
13641364
"""
13651365
Store any data inside a virtual file.
13661366
@@ -1370,22 +1370,22 @@ def virtualfile_from_data(self, data, x=None, y=None, z=None, check_kind=None):
13701370
13711371
Parameters
13721372
----------
1373-
data : str, xarray.DataArray, 2d array, or None
1374-
The vectors that will be included in the array. All must be of the
1375-
same size.
1376-
x/y/z : 1d arrays or None
1377-
x, y and z columns as numpy arrays.
13781373
check_kind : str
13791374
Used to validate the type of data that can be passed in. Choose
13801375
from 'raster', 'vector' or None. Default is None (no validation).
1376+
data : str, xarray.DataArray, 2d array, or None
1377+
Any raster or vector data format. This could be a file name, a
1378+
raster grid, a vector matrix/arrays, or other supported data input.
1379+
x/y/z : 1d arrays or None
1380+
x, y and z columns as numpy arrays.
13811381
13821382
Returns
13831383
-------
13841384
file_context : contextlib._GeneratorContextManager
13851385
The virtual file stored inside a context manager. Access the file
1386-
name of this virtualfile using `with file_context as fname: ...`.
1386+
name of this virtualfile using ``with file_context as fname: ...``.
13871387
"""
1388-
kind = data_kind(data, x, y, z, check_kind)
1388+
kind = data_kind(check_kind, data, x, y, z)
13891389

13901390
# Decide which virtualfile_from_ function to use
13911391
_virtualfile_from = {

pygmt/helpers/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pygmt.exceptions import GMTInvalidInput
1414

1515

16-
def data_kind(data, x=None, y=None, z=None, check_kind=None):
16+
def data_kind(check_kind=None, data=None, x=None, y=None, z=None):
1717
"""
1818
Check what kind of data is provided to a module.
1919
@@ -29,16 +29,16 @@ def data_kind(data, x=None, y=None, z=None, check_kind=None):
2929
3030
Parameters
3131
----------
32+
check_kind : str
33+
Used to validate the type of data that can be passed in. Choose from
34+
'raster', 'vector' or None. Default is None (no validation).
3235
data : str, xarray.DataArray, 2d array, or None
3336
Data file name, xarray.DataArray or numpy array.
3437
x/y : 1d arrays or None
3538
x and y columns as numpy arrays.
3639
z : 1d array or None
3740
z column as numpy array. To be used optionally when x and y
3841
are given.
39-
check_kind : str
40-
Used to validate the type of data that can be passed in. Choose from
41-
'raster', 'vector' or None. Default is None (no validation).
4242
4343
Returns
4444
-------

pygmt/src/grdinfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def grdinfo(grid, **kwargs):
108108
"""
109109
with GMTTempFile() as outfile:
110110
with Session() as lib:
111-
file_context = lib.virtualfile_from_data(data=grid, check_kind="raster")
111+
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
112112
with file_context as infile:
113113
arg_str = " ".join(
114114
[infile, build_arg_string(kwargs), "->" + outfile.name]

0 commit comments

Comments
 (0)