Skip to content

RFC: add ravel() (or flatten()) #658

Open
@asmeurer

Description

@asmeurer

Should we have a ravel() or flatten() function? Right now you can do it with reshape, but it's maybe not obvious. reshape also has the advantage in that it can be explicit about copying.

If not, I wonder if we should have some page or documentation somewhere to indicate the best workarounds for NumPy functions that aren't included in the standard, like "replace ravel(x) with reshape(x, (x.size,))".

Activity

rgommers

rgommers commented on Jul 16, 2023

@rgommers
Member

If not, I wonder if we should have some page or documentation somewhere to indicate the best workarounds for NumPy functions that aren't included in the standard, like "replace ravel(x) with reshape(x, (x.size,))".

I'd prefer that - keeping the standard to one way of doing things. Such a page would be useful for many users. We may also add guidance for PyTorch/JAX/etc. users there as needed.

The question is where it should live. Maybe under the Other heading in the top-level structure (see https://data-apis.org/array-api/latest/index.html)?

asmeurer

asmeurer commented on Jul 16, 2023

@asmeurer
MemberAuthor

"replace ravel(x) with reshape(x, (x.size,))".

Correction. Should be "replace ravel(x) with reshape(x, (-1,))".

linked a pull request that will close this issue on Jul 30, 2023
changed the title [-]ravel()/flatten()[/-] [+]RFC: add `ravel()` (or `flatten()`)[/+] on Apr 4, 2024
added
RFCRequest for comments. Feature requests and proposed changes.
API extensionAdds new functions or objects to the API.
topic: ManipulationArray manipulation and transformation.
on Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API extensionAdds new functions or objects to the API.Needs DiscussionNeeds further discussion.RFCRequest for comments. Feature requests and proposed changes.topic: ManipulationArray manipulation and transformation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @asmeurer@rgommers@kgryte

      Issue actions

        RFC: add `ravel()` (or `flatten()`) · Issue #658 · data-apis/array-api