ENH: clump: equivalent of clump_masked, clump_unmasked but for ordinary arrays
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
Proposed new feature or change:
I would like to have a function like np.ma.clump_masked or np.ma.clump_unmasked that I can use on ordinary arrays to find runs of elements with identical values. My application is in astronomy, where I am computing a boolean array that represents whether a target is observable in a given time step. I want to convert this to a list of time intervals.
Under the hood, both of these functions call a helper called _ezclump that has the following docstring:
Return list of slices corresponding to the unmasked clumps of a 1-D array.
(A "clump" is defined as a contiguous region of the array).
This is almost exactly what I want. (Really, I want to clump values along each row in a 2D array, and return a list of a list of slices... but this is close enough.)
This could be called np.flat_clump_nonzero or something similar.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading np.ma.clump_masked, np.ma.clump_unmasked, and their _ezclump helper, which the issue identifies as closely related entry points. Compare their 1-D behavior with the requested ordinary-array runs, then clarify the public API and 2-D row semantics. Done means the behavior and returned slice structure are specified and implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100