docs: def to_potential(f):
      '''
      to_potential(f) yields f if f is a potential function; if f is not, but f can be converted to
        a potential function, that conversion is performed then the result is yielded.
      to_potential(Ellipsis) yields a potential function whose output is simply its input (i.e., the
        identity function).
      to_potential(None) is equivalent to to_potential(0).
  
      The following can be converted into potential functions:
        * Anything for which pimms.is_array(x, 'number') yields True (i.e., arrays of constants).
        * Any tuple (g, h) where g(x) yields a potential value and h(x) yields a jacobian matrix for
          the parameter vector x.
      '''
      if   is_potential(f): return f
      elif f is Ellipsis:   return identity
      elif pimms.is_array(f, 'number'): return const_potential(f)
      elif isinstance(f, tuple) and len(f) == 2: return PotentialLambda(f[0], f[1])
      else: raise ValueError('Could not convert object to potential function')