def minkowski_distance_p(x, y, p=2):
 x = np.asarray(x)
 y = np.asarray(y)
 if (p == np.inf):
  return np.amax(np.abs((y - x)), axis=(-1))
 elif (p == 1):
  return np.sum(np.abs((y - x)), axis=(-1))
 else:
  return np.sum((np.abs((y - x)) ** p), axis=(-1))

def minkowski_distance_p ( x , y , p = 2 ) : x = np . asarray ( x ) y = np . asarray ( y ) if ( p == np . inf ) : return np . amax ( np . abs ( ( y - x ) ) , axis = ( - 1 ) ) elif ( p == 1 ) : return np . sum ( np . abs ( ( y - x ) ) , axis = ( - 1 ) ) else : return np . sum ( ( np . abs ( ( y - x ) ) ** p ) , axis = ( - 1 ) )
compute the p-th power of the l**p distance between two arrays .