def canberra(u, v):
 u = _validate_vector(u)
 v = _validate_vector(v, dtype=np.float64)
 olderr = np.seterr(invalid='ignore')
 try:
  d = np.nansum((abs((u - v)) / (abs(u) + abs(v))))
 finally:
  np.seterr(**olderr)
 return d

def canberra ( u , v ) : u = _validate_vector ( u ) v = _validate_vector ( v , dtype = np . float64 ) olderr = np . seterr ( invalid = 'ignore' ) try : d = np . nansum ( ( abs ( ( u - v ) ) / ( abs ( u ) + abs ( v ) ) ) ) finally : np . seterr ( ** olderr ) return d
computes the canberra distance between two 1-d arrays .