def __setitem__(self, key, data):
    ' Set data (deferred operation) '
    if isinstance(key, string_types):
        raise ValueError('Cannot set non-contiguous data on buffer')
    elif isinstance(key, int):
        if (key < 0):
            key += self.size
        if ((key < 0) or (key > self.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(self.size)
        if (stop < start):
            (start, stop) = (stop, start)
    elif (key == Ellipsis):
        (start, stop, step) = (0, self.size, 1)
    else:
        raise TypeError('Buffer indices must be integers or strings')
    if (step != 1):
        raise ValueError('Cannot set non-contiguous data on buffer')
    if (not isinstance(data, np.ndarray)):
        data = np.array(data, dtype=self.dtype, copy=False)
    if (data.size < (stop - start)):
        data = np.resize(data, (stop - start))
    elif (data.size > (stop - start)):
        raise ValueError('Data too big to fit GPU data.')
    offset = start
    self.set_subdata(data=data, offset=offset, copy=True)
Set data (deferred operation)
def __setitem__(self, key, data):
    '  '
    if isinstance(key, string_types):
        raise ValueError('Cannot set non-contiguous data on buffer')
    elif isinstance(key, int):
        if (key < 0):
            key += self.size
        if ((key < 0) or (key > self.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(self.size)
        if (stop < start):
            (start, stop) = (stop, start)
    elif (key == Ellipsis):
        (start, stop, step) = (0, self.size, 1)
    else:
        raise TypeError('Buffer indices must be integers or strings')
    if (step != 1):
        raise ValueError('Cannot set non-contiguous data on buffer')
    if (not isinstance(data, np.ndarray)):
        data = np.array(data, dtype=self.dtype, copy=False)
    if (data.size < (stop - start)):
        data = np.resize(data, (stop - start))
    elif (data.size > (stop - start)):
        raise ValueError('Data too big to fit GPU data.')
    offset = start
    self.set_subdata(data=data, offset=offset, copy=True)