title: KDTree return distances in all dimensions
body: <p>Using <code>scipy.spatial.KDTree()</code> in Python returns two arrays: 1.The distance to the nearest point in a list of vectors, 2. The index of the closest vector in the list. </p>
  
  <p>However the distances returned are the Euclidean distances. Is there a way to return the individual components that give the Euclidean distance?</p>
  
  <p>For example:</p>
  
  <pre><code>import numpy as np
  from scipy import spatial
  
  a = np.round(np.random.uniform(0,10,(4,2)))
  
  a
  Out[171]: 
  array([[2., 8.],
         [8., 1.],
         [6., 9.],
         [3., 6.]])
  
  f_test = np.array([8.,1.1])
  
  tree = spatial.KDTree(a)
  distances, indices = tree.query(f_test)
  
  distances
  Out[169]: 0.10000000000000009
  
  indices
  Out[170]: 1
  </code></pre>
  
  <p>Here the output of <code>distances</code> I would like is <code>[0.,0.1]</code> i.e. the distance of <code>f_test</code> to the nearest vector in <code>a</code> but in an elementwise fashion. </p>
  
  <p>NOTE:
  This is a simple example where I have only compared one vector to a 2D array of vectors but in reality I would like to return the minimum full-vector distances of a new <code>f_test</code> (which is a 2D array of test vectors) to the original array <code>a</code>. Otherwise this would be a simple problem of finding the smallest component after subtracting <code>f_test</code> from <code>a</code>. </p>
  
  <p>eg. if:</p>
  
  <pre><code>f_test = np.array([[8.,1.1],[6.,9.2]])
  </code></pre>
  
  <p>Then I would  like to return <code>distances</code> as <code>np.array([[0.,0.1],[0.,0.2]])</code></p>
  
  <p><code>KDTree</code> allows the fast calculation of minimum distances for an array of vectors with no looping hence why I'm using it as an example here. </p>
  
  <p>Link to <code>KDTree</code> docs: <a href="https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.KDTree.html" rel="nofollow noreferrer">https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.KDTree.html</a></p>