Skip to content

Conversation

@jakirkham
Copy link
Member

@jakirkham jakirkham commented Jun 21, 2019

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).

cc @pentschev

  • Tests added / passed
  • Passes flake8 dask

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).
@jakirkham
Copy link
Member Author

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)
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

@mrocklin
Copy link
Member

Would it make sense to add a small test here?

@jakirkham
Copy link
Member Author

Sure. Have pushed a small test.

@jakirkham
Copy link
Member Author

Please let me know if anything else is needed here.

@jakirkham
Copy link
Member Author

Given the discussion above, sounds like we are good to merge? Is that correct?

@pentschev
Copy link
Member

I'd say so, unless @mrocklin has any objections.

@jakirkham jakirkham merged commit 905a82d into dask:master Jun 24, 2019
@jakirkham jakirkham deleted the concat_drop_0_meta_friendly branch June 24, 2019 12:35
@jakirkham
Copy link
Member Author

Thanks all! 😄

@jakirkham jakirkham mentioned this pull request Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants