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

Implement BooleanArray #71

Merged
merged 31 commits into from
Aug 7, 2020
Merged

Conversation

asmeurer
Copy link
Member

@asmeurer asmeurer commented Jul 31, 2020

This also adds a document on type confusion (see #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.
@scopatz scopatz added this to the August 2020 milestone Aug 5, 2020
@asmeurer asmeurer marked this pull request as ready for review August 5, 2020 19:35
@asmeurer
Copy link
Member Author

asmeurer commented Aug 5, 2020

This is ready for review. I'm going to implement the remaining bits in a new PR.

@@ -24,6 +24,10 @@

__all__ += ['IntegerArray']

from .booleanarray import BooleanArray

__all__ += ['BooleanArray']
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@scopatz
Copy link
Contributor

scopatz commented Aug 5, 2020

Generally looks really good @asmeurer - just a few small changes / questions

@asmeurer asmeurer merged commit 305a266 into Quansight-Labs:master Aug 7, 2020
@ericdatakelly ericdatakelly modified the milestones: August 2020, September 2020 Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants