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

Fix broken doctest and tests on accessors #46

Merged
merged 4 commits into from
Jun 28, 2024
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
11 changes: 7 additions & 4 deletions cupy_xarray/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
register_dataarray_accessor,
register_dataset_accessor,
)
from xarray.namedarray.pycompat import DuckArrayModule

dsk = DuckArrayModule("dask")
dask_array_type = dsk.type
try:
import dask.array

dask_array_type = dask.array.Array
except ImportError:
dask_array_type = None


@register_dataarray_accessor("cupy")
Expand Down Expand Up @@ -55,7 +58,7 @@ def as_cupy(self):
>>> da = xr.tutorial.load_dataset("air_temperature").air
>>> gda = da.cupy.as_cupy()
>>> type(gda.data)
<class 'cupy.core.core.ndarray'>
<class 'cupy.ndarray'>

"""
if isinstance(self.da.data, dask_array_type):
Expand Down
8 changes: 7 additions & 1 deletion cupy_xarray/tests/test_accessors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import numpy as np
import pytest
import xarray as xr
from xarray.core.pycompat import dask_array_type

import cupy_xarray # noqa: F401

try:
import dask.array

dask_array_type = dask.array.Array
except ImportError:
dask_array_type = None


@pytest.fixture
def tutorial_ds_air():
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Running the test suite
*cupy-xarray* uses the `pytest <https://docs.pytest.org/en/latest/contents.html>`_
framework for testing. You can run the test suite using::

pytest cupy-xarray
pytest --doctest-modules cupy_xarray

Contributing documentation
==========================
Expand Down
Loading