@@ -1142,15 +1142,6 @@ def __init__(self, array):
11421142 'Trying to wrap {}' .format (type (array )))
11431143 self .array = array
11441144
1145- def _ensure_ndarray (self , value ):
1146- # We always want the result of indexing to be a NumPy array. If it's
1147- # not, then it really should be a 0d array. Doing the coercion here
1148- # instead of inside variable.as_compatible_data makes it less error
1149- # prone.
1150- if not isinstance (value , np .ndarray ):
1151- value = utils .to_0d_array (value )
1152- return value
1153-
11541145 def _indexing_array_and_key (self , key ):
11551146 if isinstance (key , OuterIndexer ):
11561147 array = self .array
@@ -1160,7 +1151,10 @@ def _indexing_array_and_key(self, key):
11601151 key = key .tuple
11611152 elif isinstance (key , BasicIndexer ):
11621153 array = self .array
1163- key = key .tuple
1154+ # We want 0d slices rather than scalars. This is achieved by
1155+ # appending an ellipsis (see
1156+ # https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#detailed-notes). # noqa
1157+ key = key .tuple + (Ellipsis ,)
11641158 else :
11651159 raise TypeError ('unexpected key type: {}' .format (type (key )))
11661160
@@ -1171,7 +1165,7 @@ def transpose(self, order):
11711165
11721166 def __getitem__ (self , key ):
11731167 array , key = self ._indexing_array_and_key (key )
1174- return self . _ensure_ndarray ( array [key ])
1168+ return array [key ]
11751169
11761170 def __setitem__ (self , key , value ):
11771171 array , key = self ._indexing_array_and_key (key )
0 commit comments