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
Adds choose method to dask.array.Array #2584
Conversation
Also adds appropriate tests
dask/array/core.py
Outdated
@@ -1307,6 +1307,10 @@ def ravel(self): | |||
|
|||
flatten = ravel | |||
|
|||
@wraps(np.choose) | |||
def choose(self, choices): | |||
return elemwise(variadic_choose, self, *choices) |
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.
Would it make sense for this to just call the function implementation or vice versa?
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.
That's a good point! It probably makes more sense to just implement choose
on a dask Array once. I'll change the PR to have the choose
function simply call the choose
method on an input dask array.
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.
Personal preference, but I'd rather have the method call the function (smaller diff too). Not a big deal though, up to you.
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.
Hey @jcrist, yeah I can switch it so that the method calls the function. I don't have a strong preference either way.
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.
Just for completeness, the argument for the function calling the method would be to handle inheritance from Dask Array. That said, I have no strong preferences here either and it can always be changed if there is a need.
One of the builds failed and it appears to be spurious, would it be possible to get a restart? |
Thanks @jrbourbeau! |
Fixes issue #2569. As mentioned in the issue, a
dask.array.choose
function already exists. This PR copies thedask.array.choose
functionality into achoose
method fordask.array.Array
objects.