Skip to content

Commit 00a5f02

Browse files
authored
pygmt.grdhisteq: Raise GMTParameterError when 'header' is used with output_type!="file" (#4398)
1 parent 00676fe commit 00a5f02

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

pygmt/src/grdhisteq.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pygmt._typing import PathLike
1212
from pygmt.alias import AliasSystem
1313
from pygmt.clib import Session
14-
from pygmt.exceptions import GMTInvalidInput
14+
from pygmt.exceptions import GMTParameterError
1515
from pygmt.helpers import (
1616
build_arg_list,
1717
fmt_docstring,
@@ -235,8 +235,10 @@ def compute_bins(
235235
output_type = validate_output_table_type(output_type, outfile=outfile)
236236

237237
if kwargs.get("h") is not None and output_type != "file":
238-
msg = "'header' is only allowed with output_type='file'."
239-
raise GMTInvalidInput(msg)
238+
raise GMTParameterError(
239+
conflicts_with=("header", [f"output_type={output_type!r}"]),
240+
reason="'header' is allowed only when 'output_type' is 'file'.",
241+
)
240242

241243
aliasdict = AliasSystem().add_common(
242244
R=region,

pygmt/tests/test_grdhisteq.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import xarray as xr
1111
from pygmt import grdhisteq
1212
from pygmt.enums import GridRegistration, GridType
13-
from pygmt.exceptions import GMTInvalidInput, GMTValueError
13+
from pygmt.exceptions import GMTParameterError, GMTValueError
1414
from pygmt.helpers import GMTTempFile
1515
from pygmt.helpers.testing import load_static_earth_relief
1616

@@ -138,5 +138,5 @@ def test_compute_bins_invalid_format(grid):
138138
"""
139139
with pytest.raises(GMTValueError):
140140
grdhisteq.compute_bins(grid=grid, output_type=1)
141-
with pytest.raises(GMTInvalidInput):
141+
with pytest.raises(GMTParameterError):
142142
grdhisteq.compute_bins(grid=grid, output_type="pandas", header="o+c")

0 commit comments

Comments
 (0)