-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement BooleanArray #71
Conversation
This will be the common superclass of IntegerArray and BooleanArray.
c.f. issue Quansight-Labs#17.
So far no methods are defined on it.
This also implements BooleanArray.count_nonzero, which returns the number of True elements of the index.
The array tests can be slower than the default 200 ms if they receive a very large list input that has to be converted into an array.
NumPy has a fast path that incorrectly compares the sizes of the array and boolean index, rather than the shapes. As a result, invalid indices can be accepted in some cases when the size but not the shapes match, and in other cases it gives the wrong exception. This is being fixed in the upstream NumPy (see the issue numbers linked in the comments). Rather than matching the broken NumPy behavior here, we do the right thing, and guard against the broken NumPy behavior in the tests.
They can all just use newshape() if the shape is given.
This is ready for review. I'm going to implement the remaining bits in a new PR. |
- Fix the documentation of the dtype attribute - Include the inherited methods from the ArrayIndex superclass - Add ArrayIndex to the internal API docs - Fix some formatting issues in some docstrings
@@ -24,6 +24,10 @@ | |||
|
|||
__all__ += ['IntegerArray'] | |||
|
|||
from .booleanarray import BooleanArray | |||
|
|||
__all__ += ['BooleanArray'] |
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.
It is odd to build up __all__
programatically like this. Seems like there should be a single definition of it
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.
I think it's a common way to do it. It keeps all the __all__
items next to their imports.
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.
Hmm weird... I don't think I have ever seen it done this way
@@ -0,0 +1,122 @@ | |||
import warnings |
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.
Please add a docstring to this module
@@ -0,0 +1,149 @@ | |||
from numpy import bool_, count_nonzero |
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.
Please add module level docstring
Generally looks really good @asmeurer - just a few small changes / questions |
It doesn't completely work, but it should hopefully work in the future.
This also adds a document on type confusion (see #17).