class_docstr: Buffer for vertex attribute data
  
  Parameters
  ----------
  data : ndarray
      Buffer data (optional)
class_docstr_tok: ["Buffer","for","vertex","attribute","data","Parameters","--","--","--","--","--","data",":","ndarray","Buffer","data","(","optional",")"]
code: def _prepare_data(self, data, convert=False):
      # Build a structured view of the data if:
      #  -> it is not already a structured array
      #  -> shape if 1-D or last dimension is 1,2,3 or 4
      if isinstance(data, list):
          data = np.array(data, dtype=np.float32)
      if not isinstance(data, np.ndarray):
          raise ValueError(
              "Data must be a ndarray (got %s)" % type(data)
          )
      if data.dtype.isbuiltin:
          if convert is True:
              data = data.astype(np.float32)
          if data.dtype in (np.float64, np.int64):
              raise TypeError("data must be 32-bit not %s" % data.dtype)
          c = data.shape[-1] if data.ndim > 1 else 1
          if c in [2, 3, 4]:
              if not data.flags["C_CONTIGUOUS"]:
                  logger.warning(
                      "Copying discontiguous data for struct "
                      "dtype:\n%s" % _last_stack_str()
                  )
                  data = data.copy()
          else:
              c = 1
          if self._last_dim and c != self._last_dim:
              raise ValueError(
                  "Last dimension should be %s not %s"
                  % (self._last_dim, c)
              )
          dtype_def = ("f0", data.dtype.base)
          if c != 1:
              # numpy dtypes with size 1 are ambiguous, only add size if it is greater than 1
              dtype_def += (c,)
          data = data.view(dtype=[dtype_def])
          self._last_dim = c
      return data
  
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 2 for calling the VertexBuffer obj's underlying member method code with example usage: obj._prepare_data(data, convert) and returns: data