Skip to content

Commit

Permalink
DOC: Docstring example for ndimage.minimum_position (scipy#8470)
Browse files Browse the repository at this point in the history
* DOC: example for ndimage.minimum_position
  • Loading branch information
rafalalgo authored and ilayn committed Feb 25, 2018
1 parent 78c97e2 commit 0b914a4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scipy/ndimage/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,33 @@ def minimum_position(input, labels=None, index=None):
label, minimum, median, maximum_position, extrema, sum, mean, variance,
standard_deviation
Examples
--------
>>> a = np.array([[10, 20, 30],
... [40, 80, 100],
... [1, 100, 200]])
>>> b = np.array([[1, 2, 0, 1],
... [5, 3, 0, 4],
... [0, 0, 0, 7],
... [9, 3, 0, 0]])
>>> from scipy import ndimage
>>> ndimage.minimum_position(a)
(2, 0)
>>> ndimage.minimum_position(b)
(0, 2)
Features to process can be specified using `labels` and `index`:
>>> label, pos = ndimage.label(a)
>>> ndimage.minimum_position(a, label, index=np.arange(1, pos+1))
[(2, 0)]
>>> label, pos = ndimage.label(b)
>>> ndimage.minimum_position(b, label, index=np.arange(1, pos+1))
[(0, 0), (0, 3), (3, 1)]
"""
dims = numpy.array(numpy.asarray(input).shape)
# see numpy.unravel_index to understand this line.
Expand Down

0 comments on commit 0b914a4

Please sign in to comment.