8
8
import xarray as xr
9
9
from pygmt ._typing import PathLike
10
10
from pygmt .clib import Session
11
- from pygmt .exceptions import GMTInvalidInput
11
+ from pygmt .exceptions import GMTInvalidInput , GMTParameterError
12
12
from pygmt .helpers import (
13
13
build_arg_list ,
14
14
deprecate_parameter ,
@@ -37,22 +37,22 @@ def _validate_params(
37
37
>>> _validate_params(constantfill=20.0, gridfill="bggrid.nc")
38
38
Traceback (most recent call last):
39
39
...
40
- pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive .
40
+ pygmt.exceptions.GMTParameterError: Mutually exclusive parameter.. .
41
41
>>> _validate_params(constantfill=20.0, inquire=True)
42
42
Traceback (most recent call last):
43
43
...
44
- pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive .
44
+ pygmt.exceptions.GMTParameterError: Mutually exclusive parameter.. .
45
45
>>> _validate_params()
46
46
Traceback (most recent call last):
47
47
...
48
48
pygmt.exceptions.GMTInvalidInput: Need to specify parameter ...
49
49
"""
50
- _fill_params = "' constantfill'/' gridfill'/' neighborfill'/' splinefill'"
50
+ _fill_params = { " constantfill" , " gridfill" , " neighborfill" , " splinefill" }
51
51
# The deprecated 'mode' parameter is given.
52
52
if mode is not None :
53
53
msg = (
54
54
"The 'mode' parameter is deprecated since v0.15.0 and will be removed in "
55
- f"v0.19.0. Use { _fill_params } instead."
55
+ f"v0.19.0. Use { ', ' . join ( repr ( par ) for par in _fill_params ) } instead."
56
56
)
57
57
warnings .warn (msg , FutureWarning , stacklevel = 2 )
58
58
@@ -61,8 +61,7 @@ def _validate_params(
61
61
for param in [constantfill , gridfill , neighborfill , splinefill , inquire , mode ]
62
62
)
63
63
if n_given > 1 : # More than one mutually exclusive parameter is given.
64
- msg = f"Parameters { _fill_params } /'inquire'/'mode' are mutually exclusive."
65
- raise GMTInvalidInput (msg )
64
+ raise GMTParameterError (exclusive = [* _fill_params , "inquire" , "mode" ])
66
65
if n_given == 0 : # No parameters are given.
67
66
msg = (
68
67
f"Need to specify parameter { _fill_params } for filling holes or "
0 commit comments