class_docstr: GPU data buffer that is aware of data type and elements size
  
  Parameters
  ----------
  data : ndarray | None
      Buffer data.
class_docstr_tok: ["GPU","data","buffer","that","is","aware","of","data","type","and","elements","size","Parameters","--","--","--","--","--","data",":","ndarray","|","None","Buffer","data","."]
docstr: Set data (deferred operation)
code: def __setitem__(self, key, data):
      """Set data (deferred operation)"""
      # Setting a whole field of the buffer: only allowed if we have CPU
      # storage. Note this case (key is string) only happen with base buffer
      if isinstance(key, str):
          raise ValueError("Cannot set non-contiguous data on buffer")
  
      # Setting one or several elements
      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")
  
      # Contiguous update?
      if step != 1:
          raise ValueError("Cannot set non-contiguous data on buffer")
  
      # Make sure data is an array
      if not isinstance(data, np.ndarray):
          data = np.array(data, dtype=self.dtype, copy=False)
  
      # Make sure data is big enough
      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 "
              "(%d > %d-%d)." % (data.size, stop, start)
          )
  
      # Set data
      offset = start
      self.set_subdata(data=data, offset=offset, copy=True)
  
imports: import numpy
  from os import path
  from traceback import extract_stack, format_list
  import weakref
  from .globject import GLObject
  from ..util import logger
label_desc: Use image node_id 13 for calling the DataBuffer obj's underlying member method code with example usage: obj.__setitem__(key, data) without return types