Skip to content

Commit 2f4466f

Browse files
committed
Fixes
1 parent 32e4d87 commit 2f4466f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pygmt/clib/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,15 +1871,15 @@ def virtualfile_in(
18711871
"equalization function like skimage.exposure.equalize_hist."
18721872
)
18731873
warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2)
1874-
case "empty": # data is None, so data must be given via x/y/z
1874+
case "empty": # data is None, so data must be given via x/y/z.
18751875
_data = [x, y]
18761876
if z is not None:
1877-
_data.append(np.atleast_1d(z))
1877+
_data.append(z)
18781878
case "vectors":
18791879
if hasattr(data, "items") and not hasattr(data, "to_frame"):
18801880
# Dict, pandas.DataFrame or xarray.Dataset types.
18811881
# pandas.Series will be handled below like a 1-D numpy.ndarray.
1882-
_data = [np.atleast_1d(array) for _, array in data.items()]
1882+
_data = [array for _, array in data.items()]
18831883
else:
18841884
# Python list, tuple, numpy.ndarray, and pandas.Series types
18851885
_data = np.atleast_2d(np.asanyarray(data).T)

pygmt/helpers/utils.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ def _validate_data_input( # noqa: PLR0912
8080
>>> _validate_data_input(
8181
... data=pd.DataFrame(data, columns=["x", "y"]),
8282
... required_cols=3,
83-
... kind="matrix",
83+
... kind="vectors",
8484
... )
8585
Traceback (most recent call last):
8686
...
8787
pygmt.exceptions.GMTInvalidInput: data needs 3 columns but 2 column(s) are given.
8888
>>> _validate_data_input(
8989
... data=xr.Dataset(pd.DataFrame(data, columns=["x", "y"])),
90+
... kind="vectors",
9091
... required_cols=3,
9192
... )
9293
Traceback (most recent call last):
@@ -122,15 +123,15 @@ def _validate_data_input( # noqa: PLR0912
122123
raise GMTInvalidInput(msg)
123124

124125
match kind:
125-
case "none":
126-
if x is None and y is None: # both x and y are None
126+
case "empty":
127+
if x is None and y is None: # Both x and y are None.
127128
msg = "No input data provided."
128129
raise GMTInvalidInput(msg)
129-
if x is None or y is None: # either x or y is None
130+
if x is None or y is None: # Either x or y is None.
130131
msg = "Must provide both x and y."
131132
raise GMTInvalidInput(msg)
132133
if required_cols >= 3 and z is None:
133-
# both x and y are not None, now check z
134+
# Both x and y are not None, now check z.
134135
msg = "Must provide x, y, and z."
135136
raise GMTInvalidInput(msg)
136137
case "matrix": # 2-D numpy.ndarray
@@ -269,9 +270,9 @@ def _check_encoding(argstr: str) -> Encoding:
269270

270271

271272
def data_kind(
272-
data: Any = None, required: bool = True
273+
data: Any, required: bool = True
273274
) -> Literal[
274-
"empty", "arg", "file", "geojson", "grid", "image", "matrix", "stringio", "vectors"
275+
"arg", "empty", "file", "geojson", "grid", "image", "matrix", "stringio", "vectors"
275276
]:
276277
r"""
277278
Check the kind of data that is provided to a module.

0 commit comments

Comments
 (0)