diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index ef497e78ebf..5dffaba58a7 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -229,13 +229,15 @@ def as_shared_dtype(scalars_or_arrays, xp=np): arrays = [asarray(x, xp=cp) for x in scalars_or_arrays] else: - arrays = [asarray(x, xp=xp) for x in scalars_or_arrays] + #arrays = [asarray(x, xp=xp) for x in scalars_or_arrays] + arrays = [x if isinstance(x, (int, float, complex)) else asarray(x, xp=xp) for x in scalars_or_arrays] # Pass arrays directly instead of dtypes to result_type so scalars # get handled properly. # Note that result_type() safely gets the dtype from dask arrays without # evaluating them. out_type = dtypes.result_type(*arrays) - return [astype(x, out_type, copy=False) for x in arrays] + #return [astype(x, out_type, copy=False) for x in arrays] + return [astype(x, out_type, copy=False) if hasattr(x, "dtype") else x for x in arrays] def broadcast_to(array, shape):