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
4 changes: 4 additions & 0 deletions pygmt/src/grdproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def grdproject( # noqa: PLR0913
msg = "Parameter 'projection' must be specified."
raise GMTInvalidInput(msg)

if kwargs.get("M", unit) is not None and kwargs.get("F", scaling) is not False:
msg = "Cannot use both 'unit' and 'scaling'."
raise GMTInvalidInput(msg)

aliasdict = AliasSystem(
C=Alias(center, name="center", sep="/", size=2),
D=Alias(spacing, name="spacing", sep="/", size=2),
Expand Down
16 changes: 16 additions & 0 deletions pygmt/tests/test_grdproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ def test_grdproject_no_outgrid(grid, projection, expected_grid):
xr.testing.assert_allclose(a=result, b=expected_grid)


def test_grdproject_unit_scaling(grid):
"""
Test that the input validation to prevent passing both 'unit' and
'scaling' is performed.
"""
with pytest.raises(GMTInvalidInput):
grdproject(
grid=grid,
projection="M10c",
spacing=3,
unit="i",
Comment thread
willschlitzer marked this conversation as resolved.
scaling="k",
region=[-53, -51, -20, -17],
)


def test_grdproject_fails(grid):
"""
Check that grdproject fails correctly.
Expand Down
Loading