Skip to content
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
4 changes: 3 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ Bug Fixes
- Fix :py:func:`decode_cf` failing on integer-encoded time arrays that contain
NaT when running against numpy 2.5+.
By `Ian Hunt-Isaak <https://github.com/ianhi>`_.

- Fix ``TypeError: Implicit conversion to a NumPy array is not allowed`` when trying to
use :py:func:`open_mfdataset` with a backend engine reading to CuPy arrays.
By `Wei Ji Leong <https://github.com/weiji14>`_.

Documentation
~~~~~~~~~~~~~
Expand Down
11 changes: 8 additions & 3 deletions xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
to_0d_array,
)
from xarray.namedarray.parallelcompat import get_chunked_array_type
from xarray.namedarray.pycompat import array_type, integer_types, is_chunked_array
from xarray.namedarray.pycompat import (
array_type,
integer_types,
is_chunked_array,
to_numpy,
)

if TYPE_CHECKING:
from xarray.core.extension_array import PandasExtensionArray
Expand Down Expand Up @@ -683,9 +688,9 @@ def __array__(
self, dtype: DTypeLike | None = None, /, *, copy: bool | None = None
) -> np.ndarray:
if Version(np.__version__) >= Version("2.0.0"):
return np.asarray(self.get_duck_array(), dtype=dtype, copy=copy)
return to_numpy(self.get_duck_array(), dtype=dtype, copy=copy)
Comment thread
dcherian marked this conversation as resolved.
Outdated
else:
return np.asarray(self.get_duck_array(), dtype=dtype)
return to_numpy(self.get_duck_array(), dtype=dtype)

def get_duck_array(self):
return self.array.get_duck_array()
Expand Down
Loading