Skip to content
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

GMTDataArrayAccessor: Support passing values using enums GridRegistration and GridType for grid registration and type #3696

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

seisman
Copy link
Member

@seisman seisman commented Dec 18, 2024

Description of proposed changes

This PR improves the GMTDataArrayAccessor by 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 enums as proposed in #499 (comment).

This PR does a few things:

  1. 8c7f8f6: Add enums GridReg/GridType.
  2. 94086f7: Update GMTDataArrayAccessor to support passing enum values (e.g., grid.gmt.registration=GridReg.PIXEL, not grid.gmt.registration=1).
  3. 8dd3d5f: Update the existing tests to check grid registration and gtype using enums (e.g., assert grid.gmt.registration==GridReg.PIXEL, not assert grid.gmt.registration==1
  4. fd099b0, f0b30ab: Update the tests in test_accessor.py

The 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:

  1. Changes in this PR are backward-compatible.
  2. String-type values (e.g., 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:

Preview: https://pygmt-dev--3696.org.readthedocs.build/en/3696/api/generated/pygmt.GMTDataArrayAccessor.html

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

@seisman seisman force-pushed the enums/grid-reg-type branch from 170a15d to fd099b0 Compare December 18, 2024 14:34
@seisman seisman added the enhancement Improving an existing feature label Dec 18, 2024
@seisman seisman marked this pull request as ready for review December 18, 2024 15:49
@seisman seisman added the needs review This PR has higher priority and needs review. label Dec 18, 2024
@seisman seisman added this to the 0.14.0 milestone Dec 18, 2024
@seisman seisman mentioned this pull request Dec 19, 2024
49 tasks
pygmt/accessors.py Outdated Show resolved Hide resolved
pygmt/tests/test_accessor.py Outdated Show resolved Hide resolved
pygmt/accessors.py Outdated Show resolved Hide resolved
@seisman seisman removed the needs review This PR has higher priority and needs review. label Dec 27, 2024
@seisman seisman modified the milestones: 0.14.0, 0.15.0 Dec 27, 2024
@seisman seisman changed the title GMTDataArrayAccessor: Support passing values using enums GridReg and GridType for grid registration and type GMTDataArrayAccessor: Support passing values using enums GridRegistration and GridType for grid registration and type Jan 5, 2025
@seisman seisman added this to the 0.15.0 milestone Jan 5, 2025
@seisman seisman added the needs review This PR has higher priority and needs review. label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature needs review This PR has higher priority and needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants