MCPcopy Create free account
hub / github.com/numpy/numpy / argmin

Function argmin

numpy/core/fromnumeric.py:1237–1325  ·  view source on GitHub ↗

Returns the indices of the minimum values along an axis. Parameters ---------- a : array_like Input array. axis : int, optional By default, the index is into the flattened array, otherwise along the specified axis. out : array, optional If pr

(a, axis=None, out=None, *, keepdims=np._NoValue)

Source from the content-addressed store, hash-verified

1235
1236@array_function_dispatch(_argmin_dispatcher)
1237def argmin(a, axis=None, out=None, *, keepdims=np._NoValue):
1238 """
1239 Returns the indices of the minimum values along an axis.
1240
1241 Parameters
1242 ----------
1243 a : array_like
1244 Input array.
1245 axis : int, optional
1246 By default, the index is into the flattened array, otherwise
1247 along the specified axis.
1248 out : array, optional
1249 If provided, the result will be inserted into this array. It should
1250 be of the appropriate shape and dtype.
1251 keepdims : bool, optional
1252 If this is set to True, the axes which are reduced are left
1253 in the result as dimensions with size one. With this option,
1254 the result will broadcast correctly against the array.
1255
1256 .. versionadded:: 1.22.0
1257
1258 Returns
1259 -------
1260 index_array : ndarray of ints
1261 Array of indices into the array. It has the same shape as `a.shape`
1262 with the dimension along `axis` removed. If `keepdims` is set to True,
1263 then the size of `axis` will be 1 with the resulting array having same
1264 shape as `a.shape`.
1265
1266 See Also
1267 --------
1268 ndarray.argmin, argmax
1269 amin : The minimum value along a given axis.
1270 unravel_index : Convert a flat index into an index tuple.
1271 take_along_axis : Apply ``np.expand_dims(index_array, axis)``
1272 from argmin to an array as if by calling min.
1273
1274 Notes
1275 -----
1276 In case of multiple occurrences of the minimum values, the indices
1277 corresponding to the first occurrence are returned.
1278
1279 Examples
1280 --------
1281 >>> a = np.arange(6).reshape(2,3) + 10
1282 >>> a
1283 array([[10, 11, 12],
1284 [13, 14, 15]])
1285 >>> np.argmin(a)
1286 0
1287 >>> np.argmin(a, axis=0)
1288 array([0, 0, 0])
1289 >>> np.argmin(a, axis=1)
1290 array([0, 0])
1291
1292 Indices of the minimum elements of a N-dimensional array:
1293
1294 >>> ind = np.unravel_index(np.argmin(a, axis=None), a.shape)

Callers

nothing calls this directly

Calls 1

_wrapfuncFunction · 0.85

Tested by

no test coverage detected