Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions pygmt/src/grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pygmt._typing import PathLike
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session, __gmt_version__
from pygmt.exceptions import GMTInvalidInput, GMTParameterError
from pygmt.exceptions import GMTParameterError
from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring, use_alias
from pygmt.src.grdinfo import grdinfo

Expand Down Expand Up @@ -80,17 +80,20 @@ def _alias_option_Q( # noqa: N802
)

if dpi is not None and surftype != "image":
msg = "Parameter 'dpi' can only be used when 'surftype' is 'image'."
raise GMTInvalidInput(msg)
raise GMTParameterError(
conflicts_with=("dpi", [f"surftype={surftype!r}"]),
reason="'dpi' is allowed only when 'surftype' is 'image'.",
)
if nan_transparent and surftype != "image":
msg = "Parameter 'nan_transparent' can only be used when 'surftype' is 'image'."
raise GMTInvalidInput(msg)
raise GMTParameterError(
conflicts_with=("nan_transparent", [f"surftype={surftype!r}"]),
reason="'nan_transparent' is allowed only when 'surftype' is 'image'.",
)
if mesh_fill is not None and surftype not in {"mesh", "waterfall_x", "waterfall_y"}:
msg = (
"Parameter 'mesh_fill' can only be used when 'surftype' is 'mesh', "
"'waterfall_x', or 'waterfall_y'."
raise GMTParameterError(
conflicts_with=("mesh_fill", [f"surftype={surftype!r}"]),
reason="'mesh_fill' is allowed only when 'surftype' is 'mesh', 'waterfall_x', or 'waterfall_y'.",
)
raise GMTInvalidInput(msg)

return [
Alias(
Expand Down
8 changes: 4 additions & 4 deletions pygmt/tests/test_grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from pygmt import Figure, grdcut
from pygmt.exceptions import GMTInvalidInput, GMTParameterError, GMTTypeError
from pygmt.exceptions import GMTParameterError, GMTTypeError
from pygmt.helpers import GMTTempFile
from pygmt.helpers.testing import load_static_earth_relief

Expand Down Expand Up @@ -330,11 +330,11 @@ def test_grdview_invalid_surftype(gridfile):
parameters.
"""
fig = Figure()
with pytest.raises(GMTInvalidInput):
with pytest.raises(GMTParameterError):
fig.grdview(grid=gridfile, surftype="surface", dpi=300)
with pytest.raises(GMTInvalidInput):
with pytest.raises(GMTParameterError):
fig.grdview(grid=gridfile, surftype="surface", nan_transparent=True)
with pytest.raises(GMTInvalidInput):
with pytest.raises(GMTParameterError):
fig.grdview(grid=gridfile, surftype="surface", mesh_fill="red")


Expand Down
Loading