def _pairwise_callable(X, Y, metric, **kwds):
 (X, Y) = check_pairwise_arrays(X, Y)
 if (X is Y):
  out = np.zeros((X.shape[0], Y.shape[0]), dtype='float')
  iterator = itertools.combinations(range(X.shape[0]), 2)
  for (i, j) in iterator:
   out[(i, j)] = metric(X[i], Y[j], **kwds)
  out = (out + out.T)
  for i in range(X.shape[0]):
   x = X[i]
   out[(i, i)] = metric(x, x, **kwds)
 else:
  out = np.empty((X.shape[0], Y.shape[0]), dtype='float')
  iterator = itertools.product(range(X.shape[0]), range(Y.shape[0]))
  for (i, j) in iterator:
   out[(i, j)] = metric(X[i], Y[j], **kwds)
 return out

def _pairwise_callable ( X , Y , metric , ** kwds ) : ( X , Y ) = check_pairwise_arrays ( X , Y ) if ( X is Y ) : out = np . zeros ( ( X . shape [ 0 ] , Y . shape [ 0 ] ) , dtype = 'float' ) iterator = itertools . combinations ( range ( X . shape [ 0 ] ) , 2 ) for ( i , j ) in iterator : out [ ( i , j ) ] = metric ( X [ i ] , Y [ j ] , ** kwds ) out = ( out + out . T ) for i in range ( X . shape [ 0 ] ) : x = X [ i ] out [ ( i , i ) ] = metric ( x , x , ** kwds ) else : out = np . empty ( ( X . shape [ 0 ] , Y . shape [ 0 ] ) , dtype = 'float' ) iterator = itertools . product ( range ( X . shape [ 0 ] ) , range ( Y . shape [ 0 ] ) ) for ( i , j ) in iterator : out [ ( i , j ) ] = metric ( X [ i ] , Y [ j ] , ** kwds ) return out
handle the callable case for pairwise_{distances .