Skip to content

Commit

Permalink
Make dask.array.utils functions more generic to other Dask Arrays
Browse files Browse the repository at this point in the history
This will be helpful for dask_expr.array, if we do that soon.
  • Loading branch information
mrocklin committed Dec 6, 2023
1 parent a8549bd commit d30b697
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dask/array/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from dask.array.core import Array
from dask.array.numpy_compat import AxisError
from dask.base import is_dask_collection
from dask.highlevelgraph import HighLevelGraph
from dask.utils import has_keyword, is_arraylike, is_cupy_type, typename

Expand Down Expand Up @@ -42,7 +43,7 @@ def meta_from_array(x, ndim=None, dtype=None):
"""
# If using x._meta, x must be a Dask Array, some libraries (e.g. zarr)
# implement a _meta attribute that are incompatible with Dask Array._meta
if hasattr(x, "_meta") and isinstance(x, Array):
if hasattr(x, "_meta") and is_dask_collection(x) and is_arraylike(x):
x = x._meta

if dtype is None and x is None:
Expand Down Expand Up @@ -255,7 +256,7 @@ def _get_dt_meta_computed(
x_meta = None
x_computed = None

if isinstance(x, Array):
if is_dask_collection(x) and is_arraylike(x):
assert x.dtype is not None
adt = x.dtype
if check_graph:
Expand Down

0 comments on commit d30b697

Please sign in to comment.