79757123

Date: 2025-09-05 20:19:41
Score: 3.5
Natty:
Report link

Did you ever check out maximum_position from scipy.ndimage?

The examples straight from their docs

>>> from scipy import ndimage
>>> import numpy as np
>>> a = np.array([[1, 2, 0, 0],
...               [5, 3, 0, 4],
...               [0, 0, 0, 7],
...               [9, 3, 0, 0]])
>>> ndimage.maximum_position(a)
(3, 0)

Features to process can be specified using `labels` and `index`:

>>> lbl = np.array([[0, 1, 2, 3],
...                 [0, 1, 2, 3],
...                 [0, 1, 2, 3],
...                 [0, 1, 2, 3]])
>>> ndimage.maximum_position(a, lbl, 1)
(1, 1)

If no index is given, non-zero `labels` are processed:

>>> ndimage.maximum_position(a, lbl)
(2, 3)

If there are no maxima, the position of the first element is returned:

>>> ndimage.maximum_position(a, lbl, 2)
(0, 2)
Reasons:
  • RegEx Blacklisted phrase (3): Did you ever
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Did you
  • Low reputation (0.5):
Posted by: Tony