feat(ai): add holes

This commit is contained in:
Kristofers Solo 2024-01-09 20:28:53 +02:00
parent 9daa4f6509
commit 00da10e482

View File

@ -4,4 +4,19 @@ import numpy as np
def holes(
field: np.ndarray[int, np.dtype[np.uint8]],
) -> int:
return 0
"""
Calculate the number of holes in each column of the given field.
Args:
field: The signal field.
peaks: Array containing peak indices. If not provided, it will be computed from the field.
Returns:
The total number of holes in the field.
"""
first_nonzero_indices = np.argmax(field != 0, axis=0)
mask = (field == 0) & (np.arange(field.shape[0])[:, np.newaxis] > first_nonzero_indices)
return int(np.sum(mask))