parameters: (obs, code_book, check_finite=True)
return_statement: return code, min_dist
docstring: Python version of vq algorithm.
  
      The algorithm computes the euclidian distance between each
      observation and every frame in the code_book.
  
      Parameters
      ----------
      obs : ndarray
          Expects a rank 2 array. Each row is one observation.
      code_book : ndarray
          Code book to use. Same format than obs. Should have same number of
          features (eg columns) than obs.
      check_finite : bool, optional
          Whether to check that the input matrices contain only finite numbers.
          Disabling may give a performance gain, but may result in problems
          (crashes, non-termination) if the inputs do contain infinities or NaNs.
          Default: True
  
      Returns
      -------
      code : ndarray
          code[i] gives the label of the ith obversation, that its code is
          code_book[code[i]].
      mind_dist : ndarray
          min_dist[i] gives the distance between the ith observation and its
          corresponding code.
  
      Notes
      -----
      This function is slower than the C version but works for
      all input types.  If the inputs have the wrong types for the
      C versions of the function, this one is called as a last resort.
  
      It is about 20 times slower than the C version.
docstring_summary: Python version of vq algorithm.
docstring_tokens: Python version of vq algorithm .
function: def py_vq(obs, code_book, check_finite=True):
      """ Python version of vq algorithm.
  
      The algorithm computes the euclidian distance between each
      observation and every frame in the code_book.
  
      Parameters
      ----------
      obs : ndarray
          Expects a rank 2 array. Each row is one observation.
      code_book : ndarray
          Code book to use. Same format than obs. Should have same number of
          features (eg columns) than obs.
      check_finite : bool, optional
          Whether to check that the input matrices contain only finite numbers.
          Disabling may give a performance gain, but may result in problems
          (crashes, non-termination) if the inputs do contain infinities or NaNs.
          Default: True
  
      Returns
      -------
      code : ndarray
          code[i] gives the label of the ith obversation, that its code is
          code_book[code[i]].
      mind_dist : ndarray
          min_dist[i] gives the distance between the ith observation and its
          corresponding code.
  
      Notes
      -----
      This function is slower than the C version but works for
      all input types.  If the inputs have the wrong types for the
      C versions of the function, this one is called as a last resort.
  
      It is about 20 times slower than the C version.
  
      """
      obs = _asarray_validated(obs, check_finite=check_finite)
      code_book = _asarray_validated(code_book, check_finite=check_finite)
  
      if obs.ndim != code_book.ndim:
          raise ValueError("Observation and code_book should have the same rank")
  
      if obs.ndim == 1:
          obs = obs[:, np.newaxis]
          code_book = code_book[:, np.newaxis]
  
      dist = cdist(obs, code_book)
      code = dist.argmin(axis=1)
      min_dist = dist[np.arange(len(code)), code]
      return code, min_dist
function_tokens: def py_vq ( obs , code_book , check_finite = True ) : obs = _asarray_validated ( obs , check_finite = check_finite ) code_book = _asarray_validated ( code_book , check_finite = check_finite ) if obs . ndim != code_book . ndim : raise ValueError ( "Observation and code_book should have the same rank" ) if obs . ndim == 1 : obs = obs [ : , np . newaxis ] code_book = code_book [ : , np . newaxis ] dist = cdist ( obs , code_book ) code = dist . argmin ( axis = 1 ) min_dist = dist [ np . arange ( len ( code ) ) , code ] return code , min_dist