-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
xarray/core/computation.py
Outdated
atop_args = [ | ||
element | ||
for (arg, dims) in zip(args, input_dims) | ||
for element in (arg, dims[-getattr(arg, 'ndim', 0) or len(dims):])] |
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.
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)
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.
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] |
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 is a good change but just so I'm clear, this was just a style correction and doesn't change the behavior, does 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.
Yes, this is just a style fix. The inner variable doesn't leak, but it's still weird to reuse it.
git diff upstream/master **/*py | flake8 --diff
whats-new.rst
for all changes andapi.rst
for new API