Skip to content

Commit 5d3d308

Browse files
committed
Rename 'required_z' to 'required_ncols' in _validate_data_input
1 parent f459ed6 commit 5d3d308

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pygmt/helpers/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

4444
def _validate_data_input(
45-
data=None, x=None, y=None, z=None, required_z=False, required_data=True, kind=None
45+
data=None, x=None, y=None, z=None, required_data=True, required_ncols=2, kind=None
4646
) -> None:
4747
"""
4848
Check if the combination of data/x/y/z is valid.
@@ -65,29 +65,29 @@ def _validate_data_input(
6565
Traceback (most recent call last):
6666
...
6767
pygmt.exceptions.GMTInvalidInput: Must provide both x and y.
68-
>>> _validate_data_input(x=[1, 2, 3], y=[4, 5, 6], required_z=True)
68+
>>> _validate_data_input(x=[1, 2, 3], y=[4, 5, 6], required_ncols=3)
6969
Traceback (most recent call last):
7070
...
7171
pygmt.exceptions.GMTInvalidInput: Must provide x, y, and z.
7272
>>> import numpy as np
7373
>>> import pandas as pd
7474
>>> import xarray as xr
7575
>>> data = np.arange(8).reshape((4, 2))
76-
>>> _validate_data_input(data=data, required_z=True, kind="matrix")
76+
>>> _validate_data_input(data=data, required_ncols=3, kind="matrix")
7777
Traceback (most recent call last):
7878
...
7979
pygmt.exceptions.GMTInvalidInput: data must provide x, y, and z columns.
8080
>>> _validate_data_input(
8181
... data=pd.DataFrame(data, columns=["x", "y"]),
82-
... required_z=True,
82+
... required_ncols=3,
8383
... kind="vectors",
8484
... )
8585
Traceback (most recent call last):
8686
...
8787
pygmt.exceptions.GMTInvalidInput: data must provide x, y, and z columns.
8888
>>> _validate_data_input(
8989
... data=xr.Dataset(pd.DataFrame(data, columns=["x", "y"])),
90-
... required_z=True,
90+
... required_ncols=3,
9191
... kind="vectors",
9292
... )
9393
Traceback (most recent call last):
@@ -115,6 +115,7 @@ def _validate_data_input(
115115
GMTInvalidInput
116116
If the data input is not valid.
117117
"""
118+
required_z = required_ncols >= 3
118119
if data is None: # data is None
119120
if x is None and y is None: # both x and y are None
120121
if required_data: # data is not optional

0 commit comments

Comments
 (0)