Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: clump: equivalent of clump_masked, clump_unmasked but for ordinary arrays #27374

Open
lpsinger opened this issue Sep 11, 2024 · 0 comments

Comments

@lpsinger
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant