diff --git a/doc/api/index.rst b/doc/api/index.rst index e1b22bbde6d..618217468c2 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -191,7 +191,6 @@ Getting metadata from tabular or grid data: .. autosummary:: :toctree: generated - GMTDataArrayAccessor info grdinfo @@ -202,6 +201,7 @@ Xarray Integration :toctree: generated GMTBackendEntrypoint + GMTDataArrayAccessor Enums ----- diff --git a/pygmt/__init__.py b/pygmt/__init__.py index d1f81094301..652c6c78712 100644 --- a/pygmt/__init__.py +++ b/pygmt/__init__.py @@ -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 @@ -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() diff --git a/pygmt/tests/test_accessor.py b/pygmt/tests/test_xarray_accessor.py similarity index 93% rename from pygmt/tests/test_accessor.py rename to pygmt/tests/test_xarray_accessor.py index 7931c39313d..1a906205f11 100644 --- a/pygmt/tests/test_accessor.py +++ b/pygmt/tests/test_xarray_accessor.py @@ -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. @@ -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. @@ -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. """ @@ -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. """ @@ -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. """ @@ -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. @@ -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. diff --git a/pygmt/xarray/__init__.py b/pygmt/xarray/__init__.py index 758b58b35dd..668ffe03db4 100644 --- a/pygmt/xarray/__init__.py +++ b/pygmt/xarray/__init__.py @@ -2,4 +2,5 @@ PyGMT integration with Xarray accessors and backends. """ +from pygmt.xarray.accessor import GMTDataArrayAccessor from pygmt.xarray.backend import GMTBackendEntrypoint diff --git a/pygmt/accessors.py b/pygmt/xarray/accessor.py similarity index 100% rename from pygmt/accessors.py rename to pygmt/xarray/accessor.py