Skip to content

pygmt.grdproject: Raise an exception when both 'unit' and 'scaling' are given#4371

Merged
seisman merged 7 commits into
GenericMappingTools:mainfrom
willschlitzer:grdproject-scaling-test
Jan 29, 2026
Merged

pygmt.grdproject: Raise an exception when both 'unit' and 'scaling' are given#4371
seisman merged 7 commits into
GenericMappingTools:mainfrom
willschlitzer:grdproject-scaling-test

Conversation

@willschlitzer

@willschlitzer willschlitzer commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

The documentation for grdproject states that it cannot have both unit and scaling set. This adds input validation and a test for it.

Closes #4334

This adds a check to see if 'unit' and 'scaling' are not both set, as the method cannot accept both inputs.
…rdproject.py.

This adds input validation for grdproject, as there is no check for both 'unit' and 'scaling'. It adds an associated test in test_grdproject.py.
@willschlitzer

Copy link
Copy Markdown
Contributor Author

I don't understand why, but the test including both unit and scaling raises an IndexError with xarray. I'm not sure why that would bypass the input validation for the kwargs.

Comment thread pygmt/src/grdproject.py Outdated
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Comment thread pygmt/src/grdproject.py Outdated
Comment thread pygmt/tests/test_grdproject.py
willschlitzer and others added 3 commits January 27, 2026 20:12
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@willschlitzer willschlitzer marked this pull request as ready for review January 28, 2026 01:24
@seisman seisman changed the title grdproject: Add input validation for 'unit' and 'scaling' pygmt.grdproject: Raise an exception when both 'unit' and 'scaling' are given Jan 28, 2026
@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Jan 28, 2026
@seisman seisman added this to the 0.19.0 milestone Jan 28, 2026
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Jan 28, 2026
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jan 29, 2026
@seisman seisman merged commit a668235 into GenericMappingTools:main Jan 29, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants