Skip to content

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

Closed

Description

@pentschev

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

Activity

  1. mrocklin commented on Feb 26, 2019

    @mrocklin
    Contributor
  2. seberg commented on Feb 26, 2019

    @seberg
    Member

    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.

  3. pentschev commented on Feb 26, 2019

    @pentschev
    ContributorAuthor

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

  4. added this to the milestone on Apr 25, 2019
  5. rgommers commented on Apr 25, 2019

    @rgommers
    Member

    PR merged, closing.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions