-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
WIP: Bitarray backed Int EAs #22238
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
WIP: Bitarray backed Int EAs #22238
Changes from 5 commits
2ff4b09
a8e8656
cae87e9
ab11480
65893ae
d2bff82
5d5117f
e085674
36256a7
384287e
2b56c99
45b45e9
29abf01
76162f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -988,7 +988,10 @@ def _set_with(self, key, value): | |
else: | ||
return self._set_values(key, value) | ||
elif key_type == 'boolean': | ||
self._set_values(key.astype(np.bool_), value) | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quite a few ways to do this but this was raising when any non-NumPy arrays were hitting this branch. Not directly related to change because it would fail for lists getting here but came to light as bitarrays were hitting this condition. |
||
self._set_values(key.astype(np.bool_), value) | ||
except AttributeError: | ||
self._set_values(key, value) | ||
else: | ||
self._set_labels(key, value) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
from functools import wraps | ||
from contextlib import contextmanager | ||
|
||
from bitarray import bitarray | ||
from numpy.random import randn, rand | ||
import numpy as np | ||
|
||
|
@@ -1172,6 +1173,13 @@ def assert_extension_array_equal(left, right): | |
assert left.dtype == right.dtype | ||
left_na = left.isna() | ||
right_na = right.isna() | ||
|
||
# TODO - maybe generate dedicated method for bitarray comparison? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment says it all - we maybe need a dedicated method for comparing bit arrays. At the very least there's got to be a more robust way of handling this in the extension check |
||
if isinstance(left_na, bitarray): | ||
left_na = np.fromstring(left_na.unpack(), dtype=bool) | ||
if isinstance(right_na, bitarray): | ||
right_na = np.fromstring(right_na.unpack(), dtype=bool) | ||
|
||
assert_numpy_array_equal(left_na, right_na) | ||
|
||
left_valid = left[~left_na].astype(object) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the method below maybe belong in a shared module, but placing here now for better change visibility