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

Allow creation of *_like() arrays of arbitrary shapes #13043

Closed
pentschev opened this issue Feb 26, 2019 · 4 comments

Comments

Projects
None yet
4 participants
@pentschev
Copy link
Contributor

commented Feb 26, 2019

Following the discussion in dask/dask#4462, in some cases it's necessary to create a new array of the same NumPy-like type (e.g., sparse or CuPy) as the input array. This can be achieved by using {empty,full,ones,zeros}_like() functions. However, this prevents a new array of arbitrary shape to be created.

@shoyer suggested the following change in dask/dask#4462:

What about adding a shape keyword argument to NumPy's zeros_like, ones_like and full_like? There's some precedence for overwriting attributes of the original array with the dtype argument already.

I think this is a good solution and I would like to see this implemented. I will be opening a PR for this soon.

@mrocklin @hameerabbasi FYI

@mrocklin

This comment has been minimized.

Copy link
Contributor

commented Feb 26, 2019

@seberg

This comment has been minimized.

Copy link
Member

commented Feb 26, 2019

The only possible downside would be if some of these get dispatched through ufuncs right now and that might make things tricky. Other then that, it seems a natural thing to just offer it.

@pentschev

This comment has been minimized.

Copy link
Contributor Author

commented Feb 26, 2019

I've sent PR #13046 for evaluation/review, please also refer to that for suggested implementation.

@rgommers rgommers added this to the 1.17.0 release milestone Apr 25, 2019

@rgommers

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

PR merged, closing.

@rgommers rgommers closed this Apr 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.