Skip to content

Fix apply_ufunc with dask='parallelized' for scalar arguments #1701

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

Merged
merged 2 commits into from
Nov 10, 2017

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Nov 8, 2017

@shoyer shoyer requested a review from jhamman November 8, 2017 22:41
atop_args = [
element
for (arg, dims) in zip(args, input_dims)
for element in (arg, dims[-getattr(arg, 'ndim', 0) or len(dims):])]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the change here is that you don't include any of the dims when arg.ndim == 0 (or ndim does exist)? That seems fine.

Style comment. This double nested list comprehension is pretty tough to read. There's just a lot going on. I might suggest rewriting it so its easier to read.

atop_args = []
for arg, dims in zip(args, input_dims):
    s = -getattr(arg, 'ndim', 0) or len(dims)
    for element in (arg, dims[s:]):
        atop_args.append(element)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the goal is to get the last ndim items from dims.

I'll rewrite this with the loop, that would indeed be clearer.

input_dims = [broadcast_dims + input_dims
for input_dims in signature.input_core_dims]
input_dims = [broadcast_dims + dims
for dims in signature.input_core_dims]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change but just so I'm clear, this was just a style correction and doesn't change the behavior, does 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.

Yes, this is just a style fix. The inner variable doesn't leak, but it's still weird to reuse it.

@shoyer shoyer merged commit 4caae2e into pydata:master Nov 10, 2017
@shoyer shoyer deleted the fix-apply-ufunc-dask-scalar branch November 10, 2017 16:48
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.

2 participants