20
20
from xarray .core .datatree_render import RenderDataTree
21
21
from xarray .core .duck_array_ops import array_all , array_any , array_equiv , astype , ravel
22
22
from xarray .core .extension_array import PandasExtensionArray
23
- from xarray .core .indexing import MemoryCachedArray
23
+ from xarray .core .indexing import (
24
+ BasicIndexer ,
25
+ ExplicitlyIndexed ,
26
+ MemoryCachedArray ,
27
+ )
24
28
from xarray .core .options import OPTIONS , _get_boolean_with_default
25
29
from xarray .core .treenode import group_subtrees
26
30
from xarray .core .utils import is_duck_array
@@ -87,6 +91,8 @@ def first_n_items(array, n_desired):
87
91
88
92
if n_desired < array .size :
89
93
indexer = _get_indexer_at_least_n_items (array .shape , n_desired , from_end = False )
94
+ if isinstance (array , ExplicitlyIndexed ):
95
+ indexer = BasicIndexer (indexer )
90
96
array = array [indexer ]
91
97
92
98
# We pass variable objects in to handle indexing
@@ -111,6 +117,8 @@ def last_n_items(array, n_desired):
111
117
112
118
if n_desired < array .size :
113
119
indexer = _get_indexer_at_least_n_items (array .shape , n_desired , from_end = True )
120
+ if isinstance (array , ExplicitlyIndexed ):
121
+ indexer = BasicIndexer (indexer )
114
122
array = array [indexer ]
115
123
116
124
# We pass variable objects in to handle indexing
@@ -659,6 +667,7 @@ def short_array_repr(array):
659
667
def short_data_repr (array ):
660
668
"""Format "data" for DataArray and Variable."""
661
669
internal_data = getattr (array , "variable" , array )._data
670
+
662
671
if isinstance (array , np .ndarray ):
663
672
return short_array_repr (array )
664
673
elif is_duck_array (internal_data ):
0 commit comments