Skip to content
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

Add dtype and order to asarray and asanyarray definitions #8106

Merged
merged 5 commits into from
Sep 7, 2021

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented Sep 1, 2021

I'll leave this here for when @pentschev gets back.

@github-actions github-actions bot added the array label Sep 1, 2021
@jakirkham
Copy link
Member

Thanks Julia! 😄 This makes a lot of sense 🙂

@jakirkham
Copy link
Member

@jrbourbeau do you have thoughts on whether we should include this in the upcoming release ( dask/community#180 )?

Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks for fixing @jsignell!

I realize it predates this PR, but should we be forwarding like, dtype, etc. keywords for the case when the input a is from xarray?

dask/array/core.py Show resolved Hide resolved
return from_array(a, getitem=getter_inline, **kwargs)


def asanyarray(a, *, like=None):
def asanyarray(a, dtype=None, order=None, *, like=None):
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment here re: docstring

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah totally! I might just steal the docstring from numpy though via a @derived_from

Copy link
Member

Choose a reason for hiding this comment

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

In general I'm in favor of using derived_from, though in this case we have an extra allow_unknown_chunksizes keyword and it looks like like has some Dask-specific verbiage. Maybe manually copying over the descriptions from NumPy makes more sense 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.

Actually I just copied them over since the like is already customized.

@jsignell
Copy link
Member Author

jsignell commented Sep 1, 2021

I realize it predates this PR, but should we be forwarding like, dtype, etc. keywords for the case when the input a is from xarray?

Good point. We should be forwarding all the kwargs IMO.

Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

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

This looks great, thanks everyone for tracking this down and @jsignell for fixing this! 😄

I requested a small change to test like= with dtype=, otherwise we're not actually testing the fix in here.

dask/array/tests/test_array_function.py Show resolved Hide resolved
@jsignell jsignell merged commit 474f479 into dask:main Sep 7, 2021
@jsignell jsignell deleted the fix-asarry-asanyarray branch September 7, 2021 15:34
@jakirkham
Copy link
Member

Thanks Peter! 🙂

@pentschev
Copy link
Member

All credit goes to @jsignell , thanks Julia! 😄

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.

TypeError in asanyarray __array_function__
4 participants