Skip to content

DOC: clarify numpy.asarray parameter 'order' meanings #29571

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
wants to merge 0 commits into from

Conversation

nbidler
Copy link

@nbidler nbidler commented Aug 15, 2025

See #28247. Changed description of options for parameter order - made explicit that 'C' and 'F' give contiguous results, and 'A' will give results equivalent to 'F' if the input is Fortran-contiguous OR non-contiguous, but if the desired output is non-contiguous Fortran-style then the user also needs to set copy to True.

'C' gives a row-major layout (C-style),
'F' gives a column-major layout (Fortran-style).
Both 'C' and 'F' ensure a contiguous result.
'A' (any) is equivalent to 'F' if input a is non-contiguous or Fortran-contiguous, otherwise, it is equivalent to 'C'. If the desired output is a non-contiguous Fortran-style ndarray, the user should set ``copy`` to ``True`` to ensure this.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please just add a minimal thing that 'A', like 'K', will not copy to ensure a contiguous output?
Yeah, maybe still confusing, so mentioning the opposite that 'C' and 'F' will copy if needed is maybe clarifying.

'A' (any) means 'F' if `a` is Fortran contiguous, 'C' otherwise
'K' (keep) preserve input order
Defaults to 'K'.
The memory layout of the output ndarray. The output of 'A' and 'K' depend on the memory layout of input a.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about simplifying this to

Suggested change
The memory layout of the output ndarray. The output of 'A' and 'K' depend on the memory layout of input a.
The memory layout of the output.

and move the explanation of the input-dependence of A and K to the individual explanations of A and K below?

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

Successfully merging this pull request may close these issues.

3 participants