gen_idx_arange
- nrv.eit.utils.gen_idx_arange(idx: ndarray | list, n: int, add_0: bool = False) ndarray[source]
Generate per-segment counters from boundary indices.
Note
this function returns a
n-long list with a conter reset to 0 at each index inidx- Parameters:
- Returns:
Counter resetting to zero at each segment boundary.
- Return type:
np.ndarray
Example
>>> gen_idx_arange([1,4,6], 10) array([0, 0, 1, 2, 0, 1, 0, 1, 2, 3]) >>> gen_idx_arange([3,6], 9) array([0, 1, 2, 0, 1, 2, 0, 1, 2]) >>> gen_idx_arange([3,6], 9, True) array([0, 0, 1, 2, 0, 1, 2, 0, 1, 2])