Skip to content

No validation that 'unit' and 'scaling' aren't both set for grdproject.py #4334

@willschlitzer

Description

@willschlitzer

Description of the problem

The documentation for grdproject.py states that unit and scaling cannot both be set. I noticed there was no internal check to make sure both aren't present. I wrote a test for it, but I'm not getting any errors when I run it with both scaling and unit set.

def test_grdproject_unit_scaling(grid):
    with GMTTempFile(suffix=".nc") as tmpfile:
        result = grdproject(
                grid=grid,
                projection="M10c",
                outgrid=tmpfile.name,
                spacing=3,
                unit="i",
                region=[-53, -51, -20, -17],
                )
        assert result is None  # return value is None
        assert Path(tmpfile.name).stat().st_size > 0  # check that outgrid exists

Is the docstring incorrect, or am I missing issues with both of these units set.

Minimal Complete Verifiable Example

if kwargs.get("M", unit) and kwargs.get("F", scaling):
        raise GMTInvalidInput("Cannot use both 'unit' and 'scaling'.")

Full error message

System information

PyGMT information:
  version: v0.3.0.dev2627+g8d5b10ba5
System information:
  python: 3.14.2 | packaged by conda-forge | (main, Dec  6 2025, 11:21:58) [GCC 14.3.0]
  executable: /envs/pygmt/bin/python
  machine: Linux-6.17.12-300.fc43.x86_64-x86_64-with-glibc2.42
Dependency information:
  numpy: 2.4.0
  pandas: 2.3.3
  xarray: 2025.12.0
  packaging: 25.0
  contextily: 1.7.0
  geopandas: 1.1.2
  IPython: 9.8.0
  pyarrow: 22.0.0
  rioxarray: 0.20.0
  gdal: 3.12.1
  ghostscript: 10.06.0
GMT library information:
  version: 6.6.0
  padding: 2
  share dir: /envs/pygmt/share/gmt
  plugin dir: /envs/pygmt/lib/gmt/plugins
  library path: /envs/pygmt/lib/libgmt.so
  cores: 8
  grid layout: rows
  image layout: 
  binary version: 6.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceBoring but important stuff for the core devs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions