# Path: zarr/errors.py
# class ArrayIndexError(IndexError):
#     pass
# 
# class NegativeStepError(IndexError):
#     def __init__(self):
#         super().__init__("only slices with step >= 1 are supported")
# 
# def err_too_many_indices(selection, shape):
#     raise IndexError('too many indices for array; expected {}, got {}'
#                      .format(len(shape), len(selection)))
# 
# class VindexInvalidSelectionError(_BaseZarrIndexError):
#     _msg = (
#         "unsupported selection type for vectorized indexing; only "
#         "coordinate selection (tuple of integer arrays) and mask selection "
#         "(single Boolean array) are supported; got {0!r}"
#     )
# 
# class BoundsCheckError(_BaseZarrIndexError):
#     _msg = "index out of bounds for dimension with length {0}"


import collections
import itertools
import math
import numbers
import numpy as np
from zarr.errors import (
    ArrayIndexError,
    NegativeStepError,
    err_too_many_indices,
    VindexInvalidSelectionError,
    BoundsCheckError,
)
        selection = ensure_tuple(selection)
        selection = replace_lists(selection)

        # validation
        if not is_mask_selection(selection, array):
            raise IndexError('invalid mask selection; expected one Boolean (mask)'
                             'array with the same shape as the target array, got {!r}'
                             .format(selection))

        # convert to indices
        selection = np.nonzero(selection[0])

        # delegate the rest to superclass
        super().__init__(selection, array)


class VIndex:

    def __init__(self, array):
        self.array = array

    def __getitem__(self, selection):
        fields, selection = pop_fields(selection)
        selection = ensure_tuple(selection)
        selection = replace_lists(selection)
        if is_coordinate_selection(selection, self.array):
            return self.array.get_coordinate_selection(selection, fields=fields)
        elif is_mask_selection(selection, self.array):
            return self.array.get_mask_selection(selection, fields=fields)
        else:

# Path: zarr/errors.py
# class ArrayIndexError(IndexError):
#     pass
# 
# class NegativeStepError(IndexError):
#     def __init__(self):
#         super().__init__("only slices with step >= 1 are supported")
# 
# def err_too_many_indices(selection, shape):
#     raise IndexError('too many indices for array; expected {}, got {}'
#                      .format(len(shape), len(selection)))
# 
# class VindexInvalidSelectionError(_BaseZarrIndexError):
#     _msg = (
#         "unsupported selection type for vectorized indexing; only "
#         "coordinate selection (tuple of integer arrays) and mask selection "
#         "(single Boolean array) are supported; got {0!r}"
#     )
# 
# class BoundsCheckError(_BaseZarrIndexError):
#     _msg = "index out of bounds for dimension with length {0}"


# Path: zarr/indexing.py
import collections
import itertools
import math
import numbers
import numpy as np
from zarr.errors import (
    ArrayIndexError,
    NegativeStepError,
    err_too_many_indices,
    VindexInvalidSelectionError,
    BoundsCheckError,
)

        selection = ensure_tuple(selection)
        selection = replace_lists(selection)

        # validation
        if not is_mask_selection(selection, array):
            raise IndexError('invalid mask selection; expected one Boolean (mask)'
                             'array with the same shape as the target array, got {!r}'
                             .format(selection))

        # convert to indices
        selection = np.nonzero(selection[0])

        # delegate the rest to superclass
        super().__init__(selection, array)


class VIndex:

    def __init__(self, array):
        self.array = array

    def __getitem__(self, selection):
        fields, selection = pop_fields(selection)
        selection = ensure_tuple(selection)
        selection = replace_lists(selection)
        if is_coordinate_selection(selection, self.array):
            return self.array.get_coordinate_selection(selection, fields=fields)
        elif is_mask_selection(selection, self.array):
            return self.array.get_mask_selection(selection, fields=fields)
        else:

            raise VindexInvalidSelectionError(selection)