def __init__(self, base, key):
    self._base = base
    self._key = key
    self._stride = base.stride
    if isinstance(key, string_types):
        self._dtype = base.dtype[key]
        self._offset = base.dtype.fields[key][1]
        self._nbytes = (base.size * self._dtype.itemsize)
        self._size = base.size
        self._itemsize = self._dtype.itemsize
        return
    if isinstance(key, int):
        if (key < 0):
            key += base.size
        if ((key < 0) or (key > base.size)):
            raise IndexError('Buffer assignment index out of range')
        (start, stop, step) = (key, (key + 1), 1)
    elif isinstance(key, slice):
        (start, stop, step) = key.indices(base.size)
        if (stop < start):
            (start, stop) = (stop, start)
    elif (key == Ellipsis):
        (start, stop, step) = (0, base.size, 1)
    else:
        raise TypeError('Buffer indices must be integers or strings')
    if (step != 1):
        raise ValueError('Cannot access non-contiguous data')
    self._itemsize = base.itemsize
    self._offset = (start * self.itemsize)
    self._size = (stop - start)
    self._dtype = base.dtype
    self._nbytes = (self.size * self.itemsize)
def __init__(self, base, key):
    self._base = base
    self._key = key
    self._stride = base.stride
    if isinstance(key, string_types):
        self._dtype = base.dtype[key]
        self._offset = base.dtype.fields[key][1]
        self._nbytes = (base.size * self._dtype.itemsize)
        self._size = base.size
        self._itemsize = self._dtype.itemsize
        return
    if isinstance(key, int):
        if (key < 0):
            key += base.size
        if ((key < 0) or (key > base.size)):
            raise IndexError('Buffer assignment index out of range')
        (start, stop, step) = (key, (key + 1), 1)
    elif isinstance(key, slice):
        (start, stop, step) = key.indices(base.size)
        if (stop < start):
            (start, stop) = (stop, start)
    elif (key == Ellipsis):
        (start, stop, step) = (0, base.size, 1)
    else:
        raise TypeError('Buffer indices must be integers or strings')
    if (step != 1):
        raise ValueError('Cannot access non-contiguous data')
    self._itemsize = base.itemsize
    self._offset = (start * self.itemsize)
    self._size = (stop - start)
    self._dtype = base.dtype
    self._nbytes = (self.size * self.itemsize)