Skip to content

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

@pentschev

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

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