# 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,
)
    def __init__(self, dim_sel, dim_len, dim_chunk_len):

        # normalize
        dim_sel = normalize_integer_selection(dim_sel, dim_len)

        # store attributes
        self.dim_sel = dim_sel
        self.dim_len = dim_len
        self.dim_chunk_len = dim_chunk_len
        self.nitems = 1

    def __iter__(self):
        dim_chunk_ix = self.dim_sel // self.dim_chunk_len
        dim_offset = dim_chunk_ix * self.dim_chunk_len
        dim_chunk_sel = self.dim_sel - dim_offset
        dim_out_sel = None
        yield ChunkDimProjection(dim_chunk_ix, dim_chunk_sel, dim_out_sel)


def ceildiv(a, b):
    return math.ceil(a / b)


class SliceDimIndexer:

    def __init__(self, dim_sel, dim_len, dim_chunk_len):

        # normalize
        self.start, self.stop, self.step = dim_sel.indices(dim_len)
        if self.step < 1:

# 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,
)

    def __init__(self, dim_sel, dim_len, dim_chunk_len):

        # normalize
        dim_sel = normalize_integer_selection(dim_sel, dim_len)

        # store attributes
        self.dim_sel = dim_sel
        self.dim_len = dim_len
        self.dim_chunk_len = dim_chunk_len
        self.nitems = 1

    def __iter__(self):
        dim_chunk_ix = self.dim_sel // self.dim_chunk_len
        dim_offset = dim_chunk_ix * self.dim_chunk_len
        dim_chunk_sel = self.dim_sel - dim_offset
        dim_out_sel = None
        yield ChunkDimProjection(dim_chunk_ix, dim_chunk_sel, dim_out_sel)


def ceildiv(a, b):
    return math.ceil(a / b)


class SliceDimIndexer:

    def __init__(self, dim_sel, dim_len, dim_chunk_len):

        # normalize
        self.start, self.stop, self.step = dim_sel.indices(dim_len)
        if self.step < 1:

            raise NegativeStepError()