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

always use dask_array_type for isinstance calls #3787

Merged
merged 2 commits into from
Feb 23, 2020
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
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ New Features

Bug fixes
~~~~~~~~~
- Use ``dask_array_type`` instead of ``dask_array.Array`` for type
checking. (:issue:`3779`, :pull:`3787`)
By `Justus Magin <https://github.com/keewis>`_.

Documentation
~~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion xarray/core/dask_array_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import numpy as np

from .pycompat import dask_array_type

try:
import dask.array as da
from dask import __version__ as dask_version
Expand Down Expand Up @@ -36,7 +38,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, da.Array):
if hasattr(x, "_meta") and isinstance(x, dask_array_type):
x = x._meta

if dtype is None and x is None:
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def f(*args, **kwargs):
dispatch_args = args[0]
else:
dispatch_args = args[array_args]
if any(isinstance(a, dask_array.Array) for a in dispatch_args):
if any(isinstance(a, dask_array_type) for a in dispatch_args):
try:
wrapped = getattr(dask_module, name)
except AttributeError as e:
Expand Down Expand Up @@ -189,8 +189,8 @@ def lazy_array_equiv(arr1, arr2):
return False
if (
dask_array
and isinstance(arr1, dask_array.Array)
and isinstance(arr2, dask_array.Array)
and isinstance(arr1, dask_array_type)
and isinstance(arr2, dask_array_type)
):
# GH3068
if arr1.name == arr2.name:
Expand Down