class_docstr: Interface for simple dictionary-based dataset format. The dictionary
  keys correspond to the column (i.e. dimension) names and the values
  are collections representing the values in that column.
class_docstr_tok: ["Interface","for","simple","dictionary-based","dataset","format",".","The","dictionary","keys","correspond","to","the","column","(","i.e",".","dimension",")","names","and","the","values","are","collections","representing","the","values","in","that","column","."]
code: def init(cls, eltype, data, kdims, vdims):
      if kdims is None:
          kdims = eltype.kdims
      if vdims is None:
          vdims = eltype.vdims
  
      dimensions = [dimension_name(d) for d in kdims + vdims]
      if (
          isinstance(data, list)
          and all(isinstance(d, dict) for d in data)
          and not all(c in d for d in data for c in dimensions)
      ):
          raise ValueError(
              "DictInterface could not find specified dimensions in the data."
          )
      elif isinstance(data, tuple):
          data = {d: v for d, v in zip(dimensions, data)}
      elif util.is_dataframe(data) and all(
          d in data for d in dimensions
      ):
          data = {d: data[d] for d in dimensions}
      elif isinstance(data, np.ndarray):
          if data.ndim == 1:
              if (
                  eltype._auto_indexable_1d
                  and len(kdims) + len(vdims) > 1
              ):
                  data = np.column_stack([np.arange(len(data)), data])
              else:
                  data = np.atleast_2d(data).T
          data = {k: data[:, i] for i, k in enumerate(dimensions)}
      elif isinstance(data, list) and data == []:
          data = dict([(d, []) for d in dimensions])
      elif isinstance(data, list) and isscalar(data[0]):
          if eltype._auto_indexable_1d:
              data = {
                  dimensions[0]: np.arange(len(data)),
                  dimensions[1]: data,
              }
          else:
              data = {dimensions[0]: data}
      elif (
          isinstance(data, list)
          and isinstance(data[0], tuple)
          and len(data[0]) == 2
          and any(isinstance(v, tuple) for v in data[0])
      ):
          dict_data = zip(
              *(
                  (util.wrap_tuple(k) + util.wrap_tuple(v))
                  for k, v in data
              )
          )
          data = {k: np.array(v) for k, v in zip(dimensions, dict_data)}
      # Ensure that interface does not consume data of other types
      # with an iterator interface
      elif not any(
          isinstance(
              data, tuple(t for t in interface.types if t is not None)
          )
          for interface in cls.interfaces.values()
      ):
          data = {k: v for k, v in zip(dimensions, zip(*data))}
      elif (
          isinstance(data, dict)
          and not any(isinstance(v, np.ndarray) for v in data.values())
          and not any(
              d in data
              or any(d in k for k in data if isinstance(k, tuple))
              for d in dimensions
          )
      ):
          # For data where both keys and values are dimension values
          # e.g. {('A', 'B'): (1, 2)} (should consider deprecating)
          dict_data = sorted(data.items())
          k, v = dict_data[0]
          if len(util.wrap_tuple(k)) != len(kdims) or len(
              util.wrap_tuple(v)
          ) != len(vdims):
              raise ValueError(
                  "Dictionary data not understood, should contain a column "
                  "per dimension or a mapping between key and value dimension "
                  "values."
              )
          dict_data = zip(
              *(
                  (util.wrap_tuple(k) + util.wrap_tuple(v))
                  for k, v in dict_data
              )
          )
          data = {k: np.array(v) for k, v in zip(dimensions, dict_data)}
  
      if not isinstance(data, cls.types):
          raise ValueError(
              "DictInterface interface couldn't convert data." ""
          )
  
      unpacked = []
      for d, vals in data.items():
          if isinstance(d, tuple):
              vals = np.asarray(vals)
              if vals.shape == (0,):
                  for sd in d:
                      unpacked.append(
                          (sd, np.array([], dtype=vals.dtype))
                      )
              elif not vals.ndim == 2 and vals.shape[1] == len(d):
                  raise ValueError(
                      "Values for %s dimensions did not have "
                      "the expected shape."
                  )
              else:
                  for i, sd in enumerate(d):
                      unpacked.append((sd, vals[:, i]))
          elif d not in dimensions:
              unpacked.append((d, vals))
          else:
              if not isscalar(vals):
                  vals = np.asarray(vals)
                  if not vals.ndim == 1 and d in dimensions:
                      raise ValueError(
                          "DictInterface expects data for each column to be flat."
                      )
              unpacked.append((d, vals))
  
      if not cls.expanded(
          [
              vs
              for d, vs in unpacked
              if d in dimensions and not isscalar(vs)
          ]
      ):
          raise ValueError(
              "DictInterface expects data to be of uniform shape."
          )
      # OrderedDict can't be replaced with dict: https://github.com/holoviz/holoviews/pull/5925
      if isinstance(data, OrderedDict):
          data.update(unpacked)
      else:
          data = OrderedDict(unpacked)
  
      return data, {"kdims": kdims, "vdims": vdims}, {}
  
imports: from collections import OrderedDict, defaultdict
  import numpy
  from ..None import util
  from ..dimension import dimension_name
  from ..element import Element
  from ..ndmapping import NdMapping, item_check, sorted_context
  from ..util import isscalar
  from .interface import DataError, Interface
label_desc: Use image node_id 2 for calling the DictInterface obj's underlying member method code with example usage: obj.init(cls, eltype, data, kdims, vdims) and returns: data,  dict,  dict