-
Notifications
You must be signed in to change notification settings - Fork 234
BREAKING: Raise GMTTypeError exception for invalid types. Previously raise GMTInvalidInput #3999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the handling of invalid-type inputs by introducing and raising a new exception class GMTTypeError instead of GMTInvalidInput. Tests across many modules have been updated to expect GMTTypeError, and source files for core commands have been modified to import and raise the new exception. Additionally, the GMTTypeError class has been added to pygmt/exceptions.py.
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pygmt/exceptions.py | Added GMTTypeError subclass of TypeError for invalid input types |
| pygmt/src/x2sys_cross.py | Switched invalid-type error from GMTInvalidInput to GMTTypeError |
| pygmt/src/text.py | Updated array‐argument checks to raise GMTTypeError |
| pygmt/src/plot3d.py | Changed invalid‐array errors to raise GMTTypeError |
| pygmt/src/plot.py | Changed invalid‐array errors to raise GMTTypeError |
| pygmt/src/legend.py | Changed invalid‐type checks to raise GMTTypeError |
| pygmt/src/grdcut.py | Switched unsupported‐type error to GMTTypeError |
| pygmt/clib/session.py | Replaced several GMTInvalidInput raises with GMTTypeError, and updated docstrings |
| pygmt/tests/* | Updated tests to import and expect GMTTypeError instead of GMTInvalidInput |
|
Ping @GenericMappingTools/pygmt-maintainers for final reivews. I plan to merge in 48 hours. |
yvonnefroehlich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with the changes, just a few minor suggestions and comments.
pygmt/src/text.py
Outdated
| raise GMTInvalidInput(msg) | ||
| raise GMTTypeError( | ||
| type(arg), | ||
| reason=f"Parameter {name!r} expects a scalar value or True.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With "scalar value", we refer to a float, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it back to "single".
Co-authored-by: Yvonne Fröhlich <[email protected]>
|
/format |
Following PR #3985. Addressing #3707 and #3984.
This PR adds a new exception
GMTTypeError. The error message is like: