8000 Allow creation of *_like() arrays of arbitrary shapes · Issue #13043 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

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

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

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

pentschev opened this issue Feb 26, 2019 · 4 comments

Comments

@pentschev
Copy link
Contributor

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
Copy link
Contributor
mrocklin commented Feb 26, 2019 via email

@seberg
Copy link
Member
seberg 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
Copy link
Contributor Author

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

PR merged, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0