Skip to content

Commit 7c1bb8d

Browse files
keewisdcherian
andauthored
explicitly skip using __array_namespace__ for numpy.ndarray (#8526)
* explicitly skip using `__array_namespace__` for `numpy.ndarray` * actually use the array in question --------- Co-authored-by: Deepak Cherian <[email protected]>
1 parent 3d6ec7e commit 7c1bb8d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

xarray/core/duck_array_ops.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ def fillna(data, other):
335335

336336
def concatenate(arrays, axis=0):
337337
"""concatenate() with better dtype promotion rules."""
338-
if hasattr(arrays[0], "__array_namespace__"):
338+
# TODO: remove the additional check once `numpy` adds `concat` to its array namespace
339+
if hasattr(arrays[0], "__array_namespace__") and not isinstance(
340+
arrays[0], np.ndarray
341+
):
339342
xp = get_array_namespace(arrays[0])
340343
return xp.concat(as_shared_dtype(arrays, xp=xp), axis=axis)
341344
return _concatenate(as_shared_dtype(arrays), axis=axis)

0 commit comments

Comments
 (0)