How to use out parameter in numpy.argmin to retrieve minimum indices?
<p>According to <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmin.html#numpy.argmin" rel="nofollow noreferrer">numpy.argmin</a> documentation, the third parameter <strong>out</strong> should provide indices (as I understand): </p>

<blockquote>
  <p><strong>out</strong> : <em>array, optional</em>
  If provided, the result will be inserted into
  this array. It should be of the appropriate shape and type.</p>
</blockquote>

<p>But I am having trouble using it to collect indices of minimum twenty of a large numpy.ndarray (<em>dist</em> in following snippet). </p>

<pre><code># here using smaller size arrays, but hold RGBs of images    
a = np.random.normal(size=(10,3))
b = np.random.normal(size=(1,3))
# compute distances between two arrays
dist = scipy.spatial.distance.cdist(a,b)
index_of_minimum = np.argmin(dist)
# create an array to hold the indices: same shape and same datatype
indices = np.array(dist.shape, dtype=np.float64)
np.argmin(dist, axis=0, out=indices)
</code></pre>

<p>But I get following error:</p>

<blockquote>
  <p>ValueError: output array does not match result of np.argmin.</p>
</blockquote>

<p>There was a similar questions asked <a href="https://stackoverflow.com/q/18582178/7073762">before</a> but my requirement is somewhat different. First, is it possible to collect indices of minimum using <em>out</em> parameter? If so how can I do that?</p>