# Buggy code
def _broadcast_indexes(self, key):
    """Prepare an indexing key for an indexing operation.

    Parameters
    -----------
    key: int, slice, array, dict or tuple of integer, slices and arrays
        Any valid input for indexing.

    Returns
    -------
    dims: tuple
        Dimension of the resultant variable.
    indexers: IndexingTuple subclass
        Tuple of integer, array-like, or slices to use when indexing
        self._data. The type of this argument indicates the type of
        indexing to perform, either basic, outer or vectorized.
    new_order : Optional[Sequence[int]]
        Optional reordering to do on the result of indexing. If not None,
        the first len(new_order) indexing should be moved to these
        positions.
    """
    key = self._item_key_to_tuple(key)  # key is a tuple
    # key is a tuple of full size
    key = indexing.expanded_indexer(key, self.ndim)
    # Convert a scalar Variable as an integer
    key = tuple(
        k.data.item() if isinstance(k, Variable) and k.ndim == 0 else k for k in key
    )

    if all(isinstance(k, BASIC_INDEXING_TYPES) for k in key):
        return self._broadcast_indexes_basic(key)

    self._validate_indexers(key)
    # Detect it can be mapped as an outer indexer
    # If all key is unlabeled, or
    # key can be mapped as an OuterIndexer.
    if all(not isinstance(k, Variable) for k in key):
        return self._broadcast_indexes_outer(key)

    # If all key is 1-dimensional and there are no duplicate labels,
    # key can be mapped as an OuterIndexer.
    dims = []
    for k, d in zip(key, self.dims):
        if isinstance(k, Variable):
            if len(k.dims) > 1:
                return self._broadcast_indexes_vectorized(key)
            dims.append(k.dims[0])
        elif not isinstance(k, integer_types):
            dims.append(d)
    if len(set(dims)) == len(dims):
        return self._broadcast_indexes_outer(key)

    return self._broadcast_indexes_vectorized(key)


# Traceback (TypeError)
In [1]: import xarray as xr
...: import numpy as np
...:
...: a = np.arange(10)
...: a[np.array(0)]
...:
Out[1]: 0

In [2]: da = xr.DataArray(a, dims='x')
...: da[np.array(0)]
...:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-d30fdfc612ec> in <module>()
1 da = xr.DataArray(a, dims='x')
----> 2 da[np.array(0)]

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/dataarray.pyc in __getitem__(self, key)
478         else:
479             # xarray-style array indexing
--> 480             return self.isel(**self._item_key_to_dict(key))
481
482     def __setitem__(self, key, value):

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/dataarray.pyc in isel(self, drop, **indexers)
759         DataArray.sel
760         """
--> 761         ds = self._to_temp_dataset().isel(drop=drop, **indexers)
762         return self._from_temp_dataset(ds)
763

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/dataset.py in isel(self, drop, **indexers)
1390         for name, var in iteritems(self._variables):
1391             var_indexers = {k: v for k, v in indexers_list if k in var.dims}
-> 1392             new_var = var.isel(**var_indexers)
1393             if not (drop and name in var_indexers):
1394                 variables[name] = new_var

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/variable.pyc in isel(self, **indexers)
851             if dim in indexers:
852                 key[i] = indexers[dim]
--> 853         return self[tuple(key)]
854
855     def squeeze(self, dim=None):

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/variable.pyc in __getitem__(self, key)
619         array `x.values` directly.
620         """
--> 621         dims, indexer, new_order = self._broadcast_indexes(key)
622         data = as_indexable(self._data)[indexer]
623         if new_order:

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/variable.pyc in _broadcast_indexes(self, key)
477         # key can be mapped as an OuterIndexer.
478         if all(not isinstance(k, Variable) for k in key):
--> 479             return self._broadcast_indexes_outer(key)
480
481         # If all key is 1-dimensional and there are no duplicate labels,

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/variable.pyc in _broadcast_indexes_outer(self, key)
542             new_key.append(k)
543
--> 544         return dims, OuterIndexer(tuple(new_key)), None
545
546     def _nonzero(self):

/home/keisukefujii/Dropbox/projects/xarray.git/xarray/core/indexing.py in __init__(self, key)
368                     raise TypeError('invalid indexer array for {}, must have '
369                                     'exactly 1 dimension: '
--> 370                                     .format(type(self).__name__, k))
371                 k = np.asarray(k, dtype=np.int64)
372             else:

TypeError: invalid indexer array for OuterIndexer, must have exactly 1 dimension:

# Fixed code
def _broadcast_indexes(self, key):
    """Prepare an indexing key for an indexing operation.

    Parameters
    -----------
    key: int, slice, array, dict or tuple of integer, slices and arrays
        Any valid input for indexing.

    Returns
    -------
    dims: tuple
        Dimension of the resultant variable.
    indexers: IndexingTuple subclass
        Tuple of integer, array-like, or slices to use when indexing
        self._data. The type of this argument indicates the type of
        indexing to perform, either basic, outer or vectorized.
    new_order : Optional[Sequence[int]]
        Optional reordering to do on the result of indexing. If not None,
        the first len(new_order) indexing should be moved to these
        positions.
    """
    key = self._item_key_to_tuple(key)  # key is a tuple
    # key is a tuple of full size
    key = indexing.expanded_indexer(key, self.ndim)
    # Convert a scalar Variable to an integer
    key = tuple(
        k.data.item() if isinstance(k, Variable) and k.ndim == 0 else k for k in key
    )
    # Convert a 0d-array to an integer
    key = tuple(
        k.item() if isinstance(k, np.ndarray) and k.ndim == 0 else k for k in key
    )

    if all(isinstance(k, BASIC_INDEXING_TYPES) for k in key):
        return self._broadcast_indexes_basic(key)

    self._validate_indexers(key)
    # Detect it can be mapped as an outer indexer
    # If all key is unlabeled, or
    # key can be mapped as an OuterIndexer.
    if all(not isinstance(k, Variable) for k in key):
        return self._broadcast_indexes_outer(key)

    # If all key is 1-dimensional and there are no duplicate labels,
    # key can be mapped as an OuterIndexer.
    dims = []
    for k, d in zip(key, self.dims):
        if isinstance(k, Variable):
            if len(k.dims) > 1:
                return self._broadcast_indexes_vectorized(key)
            dims.append(k.dims[0])
        elif not isinstance(k, integer_types):
            dims.append(d)
    if len(set(dims)) == len(dims):
        return self._broadcast_indexes_outer(key)

    return self._broadcast_indexes_vectorized(key)