88import xarray as xr
99from pygmt ._typing import PathLike
1010from pygmt .clib import Session
11- from pygmt .exceptions import GMTInvalidInput
11+ from pygmt .exceptions import GMTInvalidInput , GMTParameterError
1212from pygmt .helpers import (
1313 build_arg_list ,
1414 deprecate_parameter ,
@@ -37,22 +37,22 @@ def _validate_params(
3737 >>> _validate_params(constantfill=20.0, gridfill="bggrid.nc")
3838 Traceback (most recent call last):
3939 ...
40- pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive .
40+ pygmt.exceptions.GMTParameterError: Mutually exclusive parameter.. .
4141 >>> _validate_params(constantfill=20.0, inquire=True)
4242 Traceback (most recent call last):
4343 ...
44- pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive .
44+ pygmt.exceptions.GMTParameterError: Mutually exclusive parameter.. .
4545 >>> _validate_params()
4646 Traceback (most recent call last):
4747 ...
4848 pygmt.exceptions.GMTInvalidInput: Need to specify parameter ...
4949 """
50- _fill_params = "' constantfill'/' gridfill'/' neighborfill'/' splinefill'"
50+ _fill_params = { " constantfill" , " gridfill" , " neighborfill" , " splinefill" }
5151 # The deprecated 'mode' parameter is given.
5252 if mode is not None :
5353 msg = (
5454 "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."
5656 )
5757 warnings .warn (msg , FutureWarning , stacklevel = 2 )
5858
@@ -61,8 +61,7 @@ def _validate_params(
6161 for param in [constantfill , gridfill , neighborfill , splinefill , inquire , mode ]
6262 )
6363 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" ])
6665 if n_given == 0 : # No parameters are given.
6766 msg = (
6867 f"Need to specify parameter { _fill_params } for filling holes or "
0 commit comments