def 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)
 ct = np.common_type(obs, code_book)
 c_obs = obs.astype(ct, copy=False)
 if (code_book.dtype != ct):
  c_code_book = code_book.astype(ct)
 else:
  c_code_book = code_book
 if (ct in (np.float32, np.float64)):
  results = _vq.vq(c_obs, c_code_book)
 else:
  results = py_vq(obs, code_book)
 return results

def 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 ) ct = np . common_type ( obs , code_book ) c_obs = obs . astype ( ct , copy = False ) if ( code_book . dtype != ct ) : c_code_book = code_book . astype ( ct ) else : c_code_book = code_book if ( ct in ( np . float32 , np . float64 ) ) : results = _vq . vq ( c_obs , c_code_book ) else : results = py_vq ( obs , code_book ) return results
assign codes from a code book to observations .