Skip to content
forked from pydata/xarray

Commit

Permalink
explicitly skip using __array_namespace__ for numpy.ndarray (pyda…
Browse files Browse the repository at this point in the history
…ta#8526)

* explicitly skip using `__array_namespace__` for `numpy.ndarray`

* actually use the array in question

---------

Co-authored-by: Deepak Cherian <[email protected]>
  • Loading branch information
keewis and dcherian authored Dec 6, 2023
1 parent 3d6ec7e commit 7c1bb8d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ def fillna(data, other):

def concatenate(arrays, axis=0):
"""concatenate() with better dtype promotion rules."""
if hasattr(arrays[0], "__array_namespace__"):
# TODO: remove the additional check once `numpy` adds `concat` to its array namespace
if hasattr(arrays[0], "__array_namespace__") and not isinstance(
arrays[0], np.ndarray
):
xp = get_array_namespace(arrays[0])
return xp.concat(as_shared_dtype(arrays, xp=xp), axis=axis)
return _concatenate(as_shared_dtype(arrays), axis=axis)
Expand Down

0 comments on commit 7c1bb8d

Please sign in to comment.