# Buggy code
def normalize_array_selection(item, shape):
    """Convenience function to normalize a selection within an array with
    the given `shape`."""

    # normalize item
    if isinstance(item, numbers.Integral):
        item = (int(item),)
    elif isinstance(item, slice):
        item = (item,)
    elif item == Ellipsis:
        item = (slice(None),)

    # handle tuple of indices/slices
    if isinstance(item, tuple):
        # determine start and stop indices for all axes
        selection = tuple(normalize_axis_selection(i, l) for i, l in zip(item, shape))

        # fill out selection if not completely specified
        if len(selection) < len(shape):
            selection += tuple(slice(0, l) for l in shape[len(selection) :])

        return selection

    else:
        raise TypeError("expected indices or slice, found: %r" % item)


# Traceback (TypeError)
In [1]: import zarr

In [2]: z = zarr.empty(shape=(100, 110), chunks=(10, 11), dtype=float)

In [3]: z[0]
Out[3]:
array([  6.91088620e-310,   6.91088620e-310,   2.10918838e-316,
2.10918838e-316,   1.94607893e-316,   5.72938864e-313,
0.00000000e+000,   3.95252517e-323,   1.57027689e-312,
1.93101617e-312,   1.25197752e-312,   1.18831764e-312,
1.12465777e-312,   1.06099790e-312,   2.31297541e-312,
2.33419537e-312,   1.93101617e-312,   1.93101617e-312,
1.25197752e-312,   1.18831764e-312,   1.12465777e-312,
1.03977794e-312,   1.25197752e-312,   2.31297541e-312,
5.72938864e-313,   1.01855798e-312,   1.08221785e-312,
1.25197752e-312,   1.25197752e-312,   1.18831764e-312,
1.97345609e-312,   6.79038653e-313,   1.93101617e-312,
2.31297541e-312,   5.72938864e-313,   1.01855798e-312,
1.93101617e-312,   1.93101617e-312,   1.25197752e-312,
1.18831764e-312,   1.12465777e-312,   1.06099790e-312,
2.31297541e-312,   5.72938864e-313,   1.01855798e-312,
1.97345609e-312,   1.93101617e-312,   1.06099790e-312,
5.72938864e-313,   1.01855798e-312,   2.75859453e-313,
5.72938864e-313,   1.57027689e-312,   1.93101617e-312,
1.16709769e-312,   5.72938864e-313,   1.01855798e-312,
5.72938864e-313,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   4.94065646e-324,   6.91087535e-310,
0.00000000e+000,   4.94065646e-324,   2.45550626e-321,
6.91088620e-310,   1.98184750e-316,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
6.91087588e-310,   1.19069821e-321,   2.05561901e-316,
6.91088620e-310,   6.91070369e-310,   1.03259720e-321,
6.91088620e-310,   6.91088620e-310,   7.93037613e-120,
1.44506353e+214,   3.63859382e+185,   2.43896203e-154,
7.75110916e+228,   4.44743484e+252])

In [4]: z[0, :]
Out[4]:
array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,  0.])

In [5]: z[0, ...]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-27fbc5543985> in <module>()
----> 1 z[0, ...]

/opt/conda2/lib/python2.7/site-packages/zarr/core.pyc in __getitem__(self, item)
446
447         # normalize selection
--> 448         selection = normalize_array_selection(item, self._shape)
449
450         # determine output array shape

/opt/conda2/lib/python2.7/site-packages/zarr/util.pyc in normalize_array_selection(item, shape)
184         # determine start and stop indices for all axes
185         selection = tuple(normalize_axis_selection(i, l)
--> 186                           for i, l in zip(item, shape))
187
188         # fill out selection if not completely specified

/opt/conda2/lib/python2.7/site-packages/zarr/util.pyc in <genexpr>((i, l))
184         # determine start and stop indices for all axes
185         selection = tuple(normalize_axis_selection(i, l)
--> 186                           for i, l in zip(item, shape))
187
188         # fill out selection if not completely specified

/opt/conda2/lib/python2.7/site-packages/zarr/util.pyc in normalize_axis_selection(item, l)
163
164     else:
--> 165         raise TypeError('expected integer or slice, found: %r' % item)
166
167

TypeError: expected integer or slice, found: Ellipsis

In [6]: z[...]
Out[6]:
array([[  6.91088620e-310,   6.91088620e-310,   2.12535499e-316, ...,
0.00000000e+000,   2.28439709e-032,   6.91088696e-310],
[  0.00000000e+000,  -5.25530781e-026,   6.91088696e-310, ...,
6.91087565e-310,   3.95252517e-323,   1.41861741e-316],
[  6.91087582e-310,   4.44659081e-323,   1.41861622e-316, ...,
1.41867314e-316,   6.91087582e-310,   2.22329541e-322],
...,
[  0.00000000e+000,   0.00000000e+000,   0.00000000e+000, ...,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000],
[  0.00000000e+000,   0.00000000e+000,   0.00000000e+000, ...,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000],
[  0.00000000e+000,   0.00000000e+000,   0.00000000e+000, ...,
1.41861267e-316,   6.91087582e-310,   6.42285340e-323]])

In [7]: z[:, 0]
Out[7]:
array([  6.91088620e-310,   6.91088620e-310,   6.91087579e-310,
6.91087579e-310,   6.91087579e-310,   6.91087579e-310,
6.91087579e-310,   6.91087579e-310,   6.91087535e-310,
6.91087535e-310,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087535e-310,   3.40411230e-321,
2.03587931e-316,   6.91088620e-310,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087534e-310,   6.91087578e-310,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087282e-310,   6.91087282e-310,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087578e-310,   6.91087535e-310,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087580e-310,   6.91087580e-310,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087580e-310,   6.91087566e-310,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
1.82894873e-060,   6.91087282e-310,   6.91087582e-310,
0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
0.00000000e+000])

# Fixed code
def normalize_array_selection(item, shape):
    """Convenience function to normalize a selection within an array with
    the given `shape`."""

    # ensure tuple
    if not isinstance(item, tuple):
        item = (item,)

    # handle ellipsis
    n_ellipsis = sum(1 for i in item if i == Ellipsis)
    if n_ellipsis > 1:
        raise IndexError("an index can only have a single ellipsis ('...')")
    elif n_ellipsis == 1:
        idx_ellipsis = item.index(Ellipsis)
        n_items_l = idx_ellipsis  # items to left of ellipsis
        n_items_r = len(item) - (idx_ellipsis + 1)  # items to right of ellipsis
        n_items = len(item) - 1  # all non-ellipsis items
        if n_items >= len(shape):
            # ellipsis does nothing, just remove it
            item = tuple(i for i in item if i != Ellipsis)
        else:
            # replace ellipsis with slices
            new_item = item[:n_items_l] + ((slice(None),) * (len(shape) - n_items))
            if n_items_r:
                new_item += item[-n_items_r:]
            item = new_item

    # check dimensionality
    if len(item) > len(shape):
        raise IndexError("too many indices for array")

    # determine start and stop indices for all axes
    selection = tuple(normalize_axis_selection(i, l) for i, l in zip(item, shape))

    # fill out selection if not completely specified
    if len(selection) < len(shape):
        selection += tuple(slice(0, l) for l in shape[len(selection) :])

    return selection