Skip to content

Reorganize GMTDataArrayAccessor to the pygmt.xarray module #3928

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

Merged
merged 4 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ Getting metadata from tabular or grid data:
.. autosummary::
:toctree: generated

GMTDataArrayAccessor
info
grdinfo

Expand All @@ -202,6 +201,7 @@ Xarray Integration
:toctree: generated

GMTBackendEntrypoint
GMTDataArrayAccessor

Enums
-----
Expand Down
3 changes: 1 addition & 2 deletions pygmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# Import modules to make the high-level GMT Python API
from pygmt import datasets
from pygmt._show_versions import __commit__, __version__, show_versions
from pygmt.accessors import GMTDataArrayAccessor
from pygmt.figure import Figure, set_display
from pygmt.io import load_dataarray
from pygmt.session_management import begin as _begin
Expand Down Expand Up @@ -65,7 +64,7 @@
x2sys_init,
xyz2grd,
)
from pygmt.xarray import GMTBackendEntrypoint
from pygmt.xarray import GMTBackendEntrypoint, GMTDataArrayAccessor

# Start our global modern mode session
_begin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pygmt.exceptions import GMTInvalidInput


def test_accessor_gridline_cartesian():
def test_xarray_accessor_gridline_cartesian():
"""
Check that the accessor returns the correct registration and gtype values for a
Cartesian, gridline-registered grid.
Expand All @@ -26,7 +26,7 @@ def test_accessor_gridline_cartesian():
assert grid.gmt.gtype == GridType.CARTESIAN


def test_accessor_pixel_geographic():
def test_xarray_accessor_pixel_geographic():
"""
Check that the accessor returns the correct registration and gtype values for a
geographic, pixel-registered grid.
Expand All @@ -37,7 +37,7 @@ def test_accessor_pixel_geographic():
assert grid.gmt.gtype == GridType.GEOGRAPHIC


def test_accessor_set_registration():
def test_xarray_accessor_set_registration():
"""
Check that we can set the registration of a grid.
"""
Expand All @@ -63,7 +63,7 @@ def test_accessor_set_registration():


@pytest.mark.benchmark
def test_accessor_set_gtype():
def test_xarray_accessor_set_gtype():
"""
Check that we can set the gtype of a grid.
"""
Expand All @@ -87,7 +87,7 @@ def test_accessor_set_gtype():
assert grid.gmt.gtype == GridType.CARTESIAN == 0


def test_accessor_set_invalid_registration_and_gtype():
def test_xarray_accessor_set_invalid_registration_and_gtype():
"""
Check that setting invalid values on registration and gtype do not work.
"""
Expand All @@ -108,7 +108,7 @@ def test_accessor_set_invalid_registration_and_gtype():
condition=sys.platform == "win32" and Version(__gmt_version__) < Version("6.5.0"),
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7573",
)
def test_accessor_sliced_datacube():
def test_xarray_accessor_sliced_datacube():
"""
Check that a 2-D grid which is sliced from an n-dimensional datacube works with
accessor methods.
Expand All @@ -130,7 +130,7 @@ def test_accessor_sliced_datacube():
Path(fname).unlink()


def test_accessor_grid_source_file_not_exist():
def test_xarray_accessor_grid_source_file_not_exist():
"""
Check that the accessor fallbacks to the default registration and gtype when the
grid source file (i.e., grid.encoding["source"]) doesn't exist.
Expand Down
1 change: 1 addition & 0 deletions pygmt/xarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
PyGMT integration with Xarray accessors and backends.
"""

from pygmt.xarray.accessor import GMTDataArrayAccessor
from pygmt.xarray.backend import GMTBackendEntrypoint
File renamed without changes.