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

Masked indexing #205

Merged
merged 5 commits into from
Jul 20, 2023
Merged

Masked indexing #205

merged 5 commits into from
Jul 20, 2023

Conversation

ilanschnell
Copy link
Owner

@ilanschnell ilanschnell commented Jul 20, 2023

In this PR, we add the ability to index bitarrays by bitarrays that serve as masks which select items to be considered. For example:

>>> a =    bitarray('1001001')
>>> mask = bitarray('1010111')
>>> a[mask]  # create bitarray with items from `a` whos mask is 1
bitarray('10001')

Deletion is also possible (del a[mask] is equivalent to in-place version of selecting the inverse mask a = a[~mask]).
Masked assignment, e.g. a[mask] = 1 is not implemented, as this would be equivalent to the bitwise operation a |= mask. And a[mask] = 0 would be equivalent to a &= ~mask.

This PR addresses #190

@ilanschnell ilanschnell merged commit b9634c6 into master Jul 20, 2023
@ilanschnell ilanschnell deleted the masked branch July 25, 2023 23:41
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

Successfully merging this pull request may close these issues.

1 participant