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 2 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 cupy_xarray/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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
5 changes: 4 additions & 1 deletion cupy_xarray/tests/test_accessors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import numpy as np
import pytest
import xarray as xr
from xarray.core.pycompat import dask_array_type
from xarray.namedarray.pycompat import DuckArrayModule

import cupy_xarray # noqa: F401

dsk = DuckArrayModule("dask")
dask_array_type = dsk.type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just not do that

Suggested change
dsk = DuckArrayModule("dask")
dask_array_type = dsk.type
try:
import dask.array
dask_array_type = dask.array.Array
else:
dask_array_type = None

There is some new importlib way of doing this that I can't remember now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done at 6229f99.

There is some new importlib way of doing this that I can't remember now

Do you mean importlib.util.find_spec? That would allow us to get to the dask.array module, but not the dask.array.Array type. Unless there's another function I'm missing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that one but maybe it's not a big deal here/



@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