-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Adjust concatenate size 0 array case for meta #4979
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
Instead of hand rolling our own Dask Array creation call, dispatch to the existing ones in `wrap`. Also leverage meta to create an array of the expected type instead of using a NumPy array using `empty_like` (when `empty_like` supports this).
|
Planning on merging tomorrow if no comments. |
| return wrap.empty_like(meta, shape=shape, chunks=shape, | ||
| dtype=meta.dtype) | ||
| except TypeError: | ||
| return wrap.empty(shape, chunks=shape, dtype=meta.dtype) |
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.
You might want dask.array.utils.empty_like_safe. I think that that is what @pentschev has been using in cases like these.
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 would work here if we can skip chunks= for now (as in the behavior prior to this PR). Otherwise we need to add shape= to Dask's *_like functions, which isn't done yet. I can work on that PR if it's of immediate help.
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.
You might want
dask.array.utils.empty_like_safe.
It looked like that was just operating on NumPy arrays. Am I missing something?
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.
Correct, this is why I said that can be used if there's no need to pass chunks. I guess you need a Dask array here?
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 right. We need a Dask Array here.
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.
Then I'd say we go ahead with this, and use da.empty_like once we have shape there. I'll try to add that soon.
|
Would it make sense to add a small test here? |
|
Sure. Have pushed a small test. |
|
Please let me know if anything else is needed here. |
|
Given the discussion above, sounds like we are good to merge? Is that correct? |
|
I'd say so, unless @mrocklin has any objections. |
|
Thanks all! 😄 |
Instead of hand rolling our own Dask Array creation call, dispatch to the existing ones in
wrap. Also leverage meta to create an array of the expected type instead of using a NumPy array usingempty_like(whenempty_likesupports this).cc @pentschev
flake8 dask