html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/2414#issuecomment-420827114,https://api.github.com/repos/pydata/xarray/issues/2414,420827114,MDEyOklzc3VlQ29tbWVudDQyMDgyNzExNA==,1217238,2018-09-12T23:05:11Z,2018-09-12T23:05:11Z,MEMBER,"For reference, here is the error/traceback with xarray 0.10.8:
<details>

```python-traceback
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-a722ff347d1b> in <module>()
      3 er = xr.DataArray(np.array((np.arange(3), np.arange(6)))) # dtype=object because two different vector size
      4 print(er.data[0]) # Does work
----> 5 print(er[0]) # Does not work (ValueError)

/usr/local/lib/python3.6/dist-packages/xarray/core/dataarray.py in __getitem__(self, key)
    472         else:
    473             # xarray-style array indexing
--> 474             return self.isel(indexers=self._item_key_to_dict(key))
    475 
    476     def __setitem__(self, key, value):

/usr/local/lib/python3.6/dist-packages/xarray/core/dataarray.py in isel(self, indexers, drop, **indexers_kwargs)
    754         """"""
    755         indexers = either_dict_or_kwargs(indexers, indexers_kwargs, 'isel')
--> 756         ds = self._to_temp_dataset().isel(drop=drop, indexers=indexers)
    757         return self._from_temp_dataset(ds)
    758 

/usr/local/lib/python3.6/dist-packages/xarray/core/dataset.py in isel(self, indexers, drop, **indexers_kwargs)
   1425         for name, var in iteritems(self._variables):
   1426             var_indexers = {k: v for k, v in indexers_list if k in var.dims}
-> 1427             new_var = var.isel(indexers=var_indexers)
   1428             if not (drop and name in var_indexers):
   1429                 variables[name] = new_var

/usr/local/lib/python3.6/dist-packages/xarray/core/variable.py in isel(self, indexers, drop, **indexers_kwargs)
    852             if dim in indexers:
    853                 key[i] = indexers[dim]
--> 854         return self[tuple(key)]
    855 
    856     def squeeze(self, dim=None):

/usr/local/lib/python3.6/dist-packages/xarray/core/variable.py in __getitem__(self, key)
    622         if new_order:
    623             data = np.moveaxis(data, range(len(new_order)), new_order)
--> 624         return self._finalize_indexing_result(dims, data)
    625 
    626     def _finalize_indexing_result(self, dims, data):

/usr/local/lib/python3.6/dist-packages/xarray/core/variable.py in _finalize_indexing_result(self, dims, data)
    628         """"""
    629         return type(self)(dims, data, self._attrs, self._encoding,
--> 630                           fastpath=True)
    631 
    632     def _getitem_with_mask(self, key, fill_value=dtypes.NA):

/usr/local/lib/python3.6/dist-packages/xarray/core/variable.py in __init__(self, dims, data, attrs, encoding, fastpath)
    261         """"""
    262         self._data = as_compatible_data(data, fastpath=fastpath)
--> 263         self._dims = self._parse_dimensions(dims)
    264         self._attrs = None
    265         self._encoding = None

/usr/local/lib/python3.6/dist-packages/xarray/core/variable.py in _parse_dimensions(self, dims)
    422             raise ValueError('dimensions %s must have the same length as the '
    423                              'number of data dimensions, ndim=%s'
--> 424                              % (dims, self.ndim))
    425         return dims
    426 

ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1
```
</details>

The bottom line issue is that indexing the 1D object array returns a scalar value:
```
>>> er.data
array([array([0, 1, 2]), array([0, 1, 2, 3, 4, 5])], dtype=object)
>>> er.data[0]
array([0, 1, 2])
```
In this case, the scalar value is another 1D array, which in turn triggers the error about inconsistent dimensions.

I agree that this is a bug. We actually currently have some logic to fix another manifestation of this issue:
https://github.com/pydata/xarray/blob/4de8dbc3b1de461c0c9d3b002e55d60b46d2e6d2/xarray/core/indexing.py#L1145-L1175

This seems to be the wrong check. Instead of checking `not isinstance(value, np.ndarray)`, we should be checking to see if the array has object dtype and the indexing operation would result in a scalar (which I *think* can only happen if the unwrapped key is a tuple of integers).

Any interest in putting together a pull request? :)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,359679690