Skip to content

Commit

Permalink
Check if Dask is installed (#62)
Browse files Browse the repository at this point in the history
Fix bug so that an isinstance check doesn't require dask to be installed to work.

---------

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Co-authored-by: Justus Magin <keewis@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent ee95c00 commit c34feeb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cupy_xarray/accessors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import TYPE_CHECKING, Any

import cupy as cp
from xarray import (
DataArray,
Expand All @@ -6,12 +8,16 @@
register_dataset_accessor,
)

if TYPE_CHECKING:
DuckArrayTypes = tuple[type[Any], ...]
dask_array_type: DuckArrayTypes

try:
import dask.array

dask_array_type = dask.array.Array
dask_array_type = (dask.array.Array,)
except ImportError:
dask_array_type = None
dask_array_type = ()


@register_dataarray_accessor("cupy")
Expand Down

0 comments on commit c34feeb

Please sign in to comment.