|
30 | 30 | zeros_like, # noqa
|
31 | 31 | )
|
32 | 32 | from numpy import concatenate as _concatenate
|
33 |
| -from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] |
| 33 | +try: |
| 34 | + # numpy 2.x |
| 35 | + from numpy.lib.array_utils import normalize_axis_index # type: ignore[attr-defined] |
| 36 | +except ImportError: |
| 37 | + # numpy 1.x |
| 38 | + from numpy.core.multiarray import normalize_axis_index # type: ignore[attr-defined] |
34 | 39 | from numpy.lib.stride_tricks import sliding_window_view # noqa
|
35 | 40 |
|
36 | 41 | from xarray.core import dask_array_ops, dtypes, nputils
|
@@ -202,13 +207,15 @@ def as_shared_dtype(scalars_or_arrays, xp=np):
|
202 | 207 |
|
203 | 208 | arrays = [asarray(x, xp=cp) for x in scalars_or_arrays]
|
204 | 209 | else:
|
205 |
| - arrays = [asarray(x, xp=xp) for x in scalars_or_arrays] |
| 210 | + #arrays = [asarray(x, xp=xp) for x in scalars_or_arrays] |
| 211 | + arrays = [x if isinstance(x, (int, float, complex)) else asarray(x, xp=xp) for x in scalars_or_arrays] |
206 | 212 | # Pass arrays directly instead of dtypes to result_type so scalars
|
207 | 213 | # get handled properly.
|
208 | 214 | # Note that result_type() safely gets the dtype from dask arrays without
|
209 | 215 | # evaluating them.
|
210 | 216 | out_type = dtypes.result_type(*arrays)
|
211 |
| - return [astype(x, out_type, copy=False) for x in arrays] |
| 217 | + #return [astype(x, out_type, copy=False) for x in arrays] |
| 218 | + return [astype(x, out_type, copy=False) if hasattr(x, "dtype") else x for x in arrays] |
212 | 219 |
|
213 | 220 |
|
214 | 221 | def broadcast_to(array, shape):
|
|
0 commit comments