Skip to content

Commit 3c597d4

Browse files
committed
Fix zerodim test
1 parent f2514c7 commit 3c597d4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

xarray/core/indexing.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
from .npcompat import DTypeLike
1919
from .nputils import NumpyVIndexAdapter
2020
from .options import OPTIONS
21-
from .pycompat import dask_version, integer_types, is_duck_dask_array, sparse_array_type
21+
from .pycompat import (
22+
dask_version,
23+
integer_types,
24+
is_duck_array,
25+
is_duck_dask_array,
26+
sparse_array_type,
27+
)
2228
from .types import T_Xarray
2329
from .utils import (
2430
NDArrayMixin,
@@ -532,9 +538,11 @@ def get_duck_array(self):
532538
array = as_indexable(self.array)
533539
array = array[self.key]
534540
if isinstance(array, ExplicitlyIndexed):
535-
return array.get_duck_array()
536-
else:
537-
return array
541+
array = array.get_duck_array()
542+
if not is_duck_array(array):
543+
# This hack is necessary for 0D netCDF4 variables
544+
array = np.asarray(array)
545+
return array
538546

539547
def transpose(self, order):
540548
return LazilyVectorizedIndexedArray(self.array, self.key).transpose(order)

0 commit comments

Comments
 (0)