Skip to content

Commit 9211a90

Browse files
committed
data_kind: Change the parameter name from required_data to required
1 parent 008a56f commit 9211a90

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pygmt/clib/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ def virtualfile_in( # noqa: PLR0912
15921592
... print(fout.read().strip())
15931593
<vector memory>: N = 3 <7/9> <4/6> <1/3>
15941594
"""
1595-
kind = data_kind(data, required_data=required_data)
1595+
kind = data_kind(data, required=required_data)
15961596
validate_data_input(
15971597
data=data,
15981598
x=x,

pygmt/helpers/utils.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313
import webbrowser
1414
from collections.abc import Iterable, Sequence
15-
from typing import Any
15+
from typing import Any, Literal
1616

1717
import xarray as xr
1818
from pygmt.encodings import charset
@@ -115,7 +115,9 @@ def validate_data_input(
115115
raise GMTInvalidInput("data must provide x, y, and z columns.")
116116

117117

118-
def data_kind(data=None, required_data=True):
118+
def data_kind(
119+
data: Any = None, required: bool = True
120+
) -> Literal["arg", "file", "geojson", "grid", "image", "matrix", "vectors"]:
119121
"""
120122
Check what kind of data is provided to a module.
121123
@@ -137,15 +139,14 @@ def data_kind(data=None, required_data=True):
137139
Pass in either a file name or :class:`pathlib.Path` to an ASCII data
138140
table, an :class:`xarray.DataArray`, a 1-D/2-D
139141
{table-classes} or an option argument.
140-
required_data : bool
142+
required
141143
Set to True when 'data' is required, or False when dealing with
142144
optional virtual files. [Default is True].
143145
144146
Returns
145147
-------
146-
kind : str
147-
One of ``'arg'``, ``'file'``, ``'grid'``, ``image``, ``'geojson'``,
148-
``'matrix'``, or ``'vectors'``.
148+
kind
149+
The data kind.
149150
150151
Examples
151152
--------
@@ -179,7 +180,7 @@ def data_kind(data=None, required_data=True):
179180
):
180181
# One or more files
181182
kind = "file"
182-
elif isinstance(data, bool | int | float) or (data is None and not required_data):
183+
elif isinstance(data, bool | int | float) or (data is None and not required):
183184
kind = "arg"
184185
elif isinstance(data, xr.DataArray):
185186
kind = "image" if len(data.dims) == 3 else "grid"

0 commit comments

Comments
 (0)