diff --git a/pygmt/src/grdgradient.py b/pygmt/src/grdgradient.py index 93acdc213ea..b3131435fec 100644 --- a/pygmt/src/grdgradient.py +++ b/pygmt/src/grdgradient.py @@ -9,7 +9,7 @@ from pygmt._typing import PathLike from pygmt.alias import Alias, AliasSystem from pygmt.clib import Session -from pygmt.exceptions import GMTInvalidInput, GMTParameterError +from pygmt.exceptions import GMTParameterError from pygmt.helpers import build_arg_list, fmt_docstring, use_alias __doctest_skip__ = ["grdgradient"] @@ -54,12 +54,13 @@ def _alias_option_N( # noqa: N802 v is not None and v is not False for v in [norm_amp, norm_ambient, norm_sigma, norm_offset] ): - msg = ( - "Parameter 'normalize' using old syntax with raw GMT CLI string " - "conflicts with parameters 'norm_amp', 'norm_ambient', 'norm_sigma', " - "or 'norm_offset'." + raise GMTParameterError( + conflicts_with=( + "normalize", + ["norm_amp", "norm_ambient", "norm_sigma", "norm_offset"], + ), + reason="'normalize' is specified using the unrecommended GMT command string syntax.", ) - raise GMTInvalidInput(msg) _normalize_mapping = None return [ diff --git a/pygmt/tests/test_grdgradient.py b/pygmt/tests/test_grdgradient.py index e5d9616a3fb..cf8f64fa987 100644 --- a/pygmt/tests/test_grdgradient.py +++ b/pygmt/tests/test_grdgradient.py @@ -8,7 +8,7 @@ import xarray as xr from pygmt import grdgradient from pygmt.enums import GridRegistration, GridType -from pygmt.exceptions import GMTInvalidInput, GMTParameterError +from pygmt.exceptions import GMTParameterError from pygmt.helpers import GMTTempFile from pygmt.helpers.testing import load_static_earth_relief @@ -75,17 +75,17 @@ def test_grdgradient_no_outgrid(grid, expected_grid): def test_grdgradient_normalize_mixed_syntax(grid): """ - Test that mixed syntax for normalize in grdgradient raises GMTInvalidInput. + Test that mixed syntax for normalize in grdgradient raises GMTParameterError. """ - with pytest.raises(GMTInvalidInput): + with pytest.raises(GMTParameterError): grdgradient(grid=grid, azimuth=10, normalize="t", norm_amp=2) - with pytest.raises(GMTInvalidInput): + with pytest.raises(GMTParameterError): grdgradient(grid=grid, azimuth=10, normalize="t1", norm_amp=2) - with pytest.raises(GMTInvalidInput): + with pytest.raises(GMTParameterError): grdgradient(grid=grid, azimuth=10, normalize="t1", norm_sigma=2) - with pytest.raises(GMTInvalidInput): + with pytest.raises(GMTParameterError): grdgradient(grid=grid, azimuth=10, normalize="e", norm_offset=5) - with pytest.raises(GMTInvalidInput): + with pytest.raises(GMTParameterError): grdgradient(grid=grid, azimuth=10, normalize="e", norm_ambient=0.1)