Skip to content

Conversation

@shoyer
Copy link
Member

@shoyer shoyer commented Aug 28, 2019

da.asanyarray() currently crashes if passed a datetime64 dtype array, as noted
in pydata/xarray#3220:

>       elif hasattr(a, "data") and type(a).__module__.startswith("xarray."):
E       ValueError: cannot include dtype 'M' in a buffer

Reversing the order of these checks fixes the issue. (.data is an attribute of NumPy arrays that creates a buffer, which isn't valid for datetime dtypes.)

I also adjusted da.asarray() to coerce xarray objects in the same way as da.asanyarray().

  • Tests added / passed
  • Passes black dask / flake8 dask

…jects.

`da.asanyarray()` current crashes if passed a datetime64 dtype array, as noted
in pydata/xarray#3220:

    >       elif hasattr(a, "data") and type(a).__module__.startswith("xarray."):
    E       ValueError: cannot include dtype 'M' in a buffer

Reversing the order of these checks fixes the issue.

I also adjusted `da.asarray()` to coerce xarray objects in the same way as
`da.asanyarray()`.
@shoyer shoyer mentioned this pull request Aug 28, 2019
1 task
@mrocklin
Copy link
Member

Looks good to me. There might be a small typo (I think). Suggestion above.

@shoyer shoyer merged commit bf66e7c into dask:master Aug 29, 2019
@shoyer shoyer deleted the asarray-fixup branch August 29, 2019 02:29
@shoyer
Copy link
Member Author

shoyer commented Aug 29, 2019

@mrocklin Thanks for catching my error!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants