Uh oh!
There was an error while loading. Please reload this page.
GMTDataArrayAccessor: Support passing values using enums GridRegistration and GridType for grid registration and type - #3696
Conversation
170a15d to
fd099b0CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| f"Invalid grid registration value: {value}, should be either " | ||
| "0 for Gridline registration or 1 for Pixel registration." | ||
| f"Invalid grid registration: '{value}'. " | ||
| "Should be either GridRegistration.GRIDLINE or GridRegistration.PIXEL." |
There was a problem hiding this comment.
Should we still mention the integer value of the enum? E.g. have the error message be:
"Should be either GridRegistration.GRIDLINE (0) or GridRegistration.PIXEL (1)."
Thoughts?
| grid source file (i.e., grid.encoding["source"]) doesn't exist. | ||
| """ | ||
| # Load the 05m earth relief grid, which is stored as tiles | ||
| # Load the 05m earth relief grid, which is stored as tiles. |
There was a problem hiding this comment.
Do comments need to end with a full stop now?
There was a problem hiding this comment.
That's just my preference, since it's a complete sentence.
There was a problem hiding this comment.
Ah ok, I was afraid that you were using some experimental ruff linter 😆!
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Description of proposed changes
This PR improves the
GMTDataArrayAccessorby allowing setting grid registration and gtype using more readable enums, rather than numeric values.Refer to #499 (comment) for the initial thoughts but implemented using
enumsas proposed in #499 (comment).This PR does a few things:
GridReg/GridType.GMTDataArrayAccessorto support passing enum values (e.g.,grid.gmt.registration=GridReg.PIXEL, notgrid.gmt.registration=1).assert grid.gmt.registration==GridReg.PIXEL, notassert grid.gmt.registration==1test_accessor.pyThe plan is to cherry-pick the commit 8c7f8f6 into a separate PR and keep the other commits in this PR, so that we can have two separate entries in the release changelog.[Done in #3693]Please note that:
grid.gmt.registration = "gridline") initially proposed in Make a gmt xarray accessor to store metadata from grdinfo #499 (comment) are not supported in this PR. It's simple to support string-type values, but I feel it's not necessary (see the reverted changes in 259771a).TODO:
GridReg/GridTypeto API docs [in Add enums GridRegistration and GridType for grid registration and type #3693]Preview: https://pygmt-dev--3696.org.readthedocs.build/en/3696/api/generated/pygmt.GMTDataArrayAccessor.html
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.