Skip to content

Commit e3493b0

Browse files
committed
Revert "Try updating result_type for array API"
This reverts commit 3f7670b.
1 parent 6115dd8 commit e3493b0

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

xarray/core/dtypes.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ def is_datetime_like(dtype):
168168

169169
def result_type(
170170
*arrays_and_dtypes: np.typing.ArrayLike | np.typing.DTypeLike,
171-
xp=np,
172171
) -> np.dtype:
173172
"""Like np.result_type, but with type promotion rules matching pandas.
174173
@@ -185,13 +184,12 @@ def result_type(
185184
-------
186185
numpy.dtype for the result.
187186
"""
188-
types = {xp.result_type(t) for t in arrays_and_dtypes}
187+
types = {np.result_type(t).type for t in arrays_and_dtypes}
189188

190-
if xp == np:
191-
for left, right in PROMOTE_TO_OBJECT:
192-
if any(issubclass(t.type, left) for t in types) and any(
193-
issubclass(t.type, right) for t in types
194-
):
195-
return np.dtype(object)
189+
for left, right in PROMOTE_TO_OBJECT:
190+
if any(issubclass(t, left) for t in types) and any(
191+
issubclass(t, right) for t in types
192+
):
193+
return np.dtype(object)
196194

197-
return xp.result_type(*arrays_and_dtypes)
195+
return np.result_type(*arrays_and_dtypes)

xarray/core/duck_array_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def as_shared_dtype(scalars_or_arrays, xp=np):
239239
# get handled properly.
240240
# Note that result_type() safely gets the dtype from dask arrays without
241241
# evaluating them.
242-
out_type = dtypes.result_type(*arrays, xp=xp)
242+
out_type = dtypes.result_type(*arrays)
243243
return [
244244
astype(x, out_type, copy=False) if hasattr(x, "dtype") else x for x in arrays
245245
]

0 commit comments

Comments
 (0)