43
43
44
44
45
45
def _validate_data_input ( # noqa: PLR0912
46
- data = None , x = None , y = None , z = None , required_z = False , required_data = True , kind = None
46
+ data = None , x = None , y = None , z = None , mincols = 2 , required_data = True , kind = None
47
47
) -> None :
48
48
"""
49
49
Check if the combination of data/x/y/z is valid.
@@ -66,29 +66,29 @@ def _validate_data_input( # noqa: PLR0912
66
66
Traceback (most recent call last):
67
67
...
68
68
pygmt.exceptions.GMTInvalidInput: Must provide both x and y.
69
- >>> _validate_data_input(x=[1, 2, 3], y=[4, 5, 6], required_z=True )
69
+ >>> _validate_data_input(x=[1, 2, 3], y=[4, 5, 6], mincols=3 )
70
70
Traceback (most recent call last):
71
71
...
72
72
pygmt.exceptions.GMTInvalidInput: Must provide x, y, and z.
73
73
>>> import numpy as np
74
74
>>> import pandas as pd
75
75
>>> import xarray as xr
76
76
>>> data = np.arange(8).reshape((4, 2))
77
- >>> _validate_data_input(data=data, required_z=True , kind="matrix")
77
+ >>> _validate_data_input(data=data, mincols=3 , kind="matrix")
78
78
Traceback (most recent call last):
79
79
...
80
80
pygmt.exceptions.GMTInvalidInput: data must provide x, y, and z columns.
81
81
>>> _validate_data_input(
82
82
... data=pd.DataFrame(data, columns=["x", "y"]),
83
- ... required_z=True ,
83
+ ... mincols=3 ,
84
84
... kind="vectors",
85
85
... )
86
86
Traceback (most recent call last):
87
87
...
88
88
pygmt.exceptions.GMTInvalidInput: data must provide x, y, and z columns.
89
89
>>> _validate_data_input(
90
90
... data=xr.Dataset(pd.DataFrame(data, columns=["x", "y"])),
91
- ... required_z=True ,
91
+ ... mincols=3 ,
92
92
... kind="vectors",
93
93
... )
94
94
Traceback (most recent call last):
@@ -116,6 +116,7 @@ def _validate_data_input( # noqa: PLR0912
116
116
GMTInvalidInput
117
117
If the data input is not valid.
118
118
"""
119
+ required_z = mincols >= 3
119
120
if data is None : # data is None
120
121
if x is None and y is None : # both x and y are None
121
122
if required_data : # data is not optional
0 commit comments