code: def get_dist(archive, func, keymap=None):
      """get the graphical distance of func from data in archive
  
      Args:
          archive (klepto.archive): run archive (output of ``read``)
          func (function): with interface ``y = f(x)``, ``x`` is a list of floats
          keymap (klepto.keymap): keymap used for key encoding
  
      Returns:
          array of floats, graphical distance from func to each point in archive
      """
      from mystic.math.legacydata import dataset
  
      data = dataset()
      arxiv = getattr(archive, "__archive__", archive)
      if not len(arxiv):
          return
      # FIXME: need to implement generalized inverse of keymap
      # HACK: only works in certain special cases
      kind = getattr(keymap, "__stub__", "")
      if kind in (
          "encoding",
          "algorithm",
      ):  # FIXME always assumes used repr
          inv = lambda k: eval(k)
      elif kind in ("serializer",):  # FIXME: ignores all config options
          import importlib
  
          inv = lambda k: importlib.import_module(
              keymap.__type__
          ).loads(k)
      else:  # FIXME: give up, ignore keymap
          inv = lambda k: k
      y = ((inv(k), v) for k, v in arxiv.items())
      # HACK end
      import numpy as np
  
      y = np.array(list(y), dtype=object).T
      data.load(
          y[0].tolist(), y[1].tolist(), ids=list(range(len(y[0])))
      )
      from mystic.math.distance import graphical_distance
  
      return graphical_distance(func, data)
  
file_path: mystic/mystic/cache/archive.py
imports: from klepto.archives import dict_archive, dir_archive, file_archive, hdf_archive, hdfdir_archive, null_archive, sql_archive, sqltable_archive
label_desc: Use image node_id 6 for calling a global function with example usage: get_dist(archive, func, keymap) and returns: graphical_distance