8000 DOC: Unify cross-references between array joining methods by timhoffm · Pull Request #16197 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: Unify cross-references between array joining methods #16197

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

Merged
merged 1 commit into from
May 15, 2020

Conversation

timhoffm
Copy link
Contributor

Essentially, always reference the following functions:

    concatenate
    stack
    vstack
    hstack
    dstack
    column_stack
    block

but omitting the documented function itself (of course), and appending the corresponding inverse split operation instead.

In particular:

  • unified the order.
  • updated descriptions from docstring summary.

vstack : Stack arrays in sequence vertically (row wise).
hstack : Stack arrays in sequence horizontally (column wise).
dstack : Stack arrays in sequence depth wise (along third axis).
column_stack : Stack 1-D arrays as columns into a 2-D array.
Copy link
Member

Choose a reason for hiding this comment

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

I think omitting these four might have been deliberate, as stack is a more predictable replacement for all of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not following. Do you mean one should always use stack instead of these? If so, that should be noted explicitly in the above functions. If not, I don't see why one should not link to these other and more specialized functions.

Copy link
Member
@eric-wieser eric-wieser May 10, 2020

Choose a reason for hiding this comment

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

Here's the reference I was looking for: #7183 (comment):

I actually intentionally omitted vstack and hstack from the docstring for stack, because these routines are less general and powerful than stack and concatenate. The way that vstack/hstack/dstack handle arrays of different dimensionality is quirky and difficult to predict for most people without experimentation. In contrast, stack and concatenate are a better fit for NumPy as a library for manipulating N-dimensional arrays. -- @shoyer

Copy link
Member

Choose a reason for hiding this comment

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

#7253 added links in the other direction recommending stack be used instead.

Copy link
Contributor Author
@timhoffm timhoffm May 10, 2020

Choose a reason for hiding this comment

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

I've removed the links again as I don't want to go down a long API discussion. This is just intended as a small doc fix.

Note however, that the wording was alleviated in #10057, but the wording is IMHO too vague. With my user hat on, I still don't know what the recommended way of working is. Can / should or shouldn't I use vstack? It would be ok to keep it in the API but recommend to use stack in which case we shouldn't link from stack to vstack. Note also that concatenate and block still link to the *stack variants. That should be removed as well if the intention is to reduce visibility of *stack.

vstack
hstack
dstack
column_stack
block
Copy link
Member

Choose a reason for hiding this comment

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

I'd be tempted to put block immediately below stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +150 to +151
ma.vstack
ma.hstack
Copy link
Member

Choose a reason for hiding this comment

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

Nit: below you put h before v

@seberg
Copy link
Member
seberg commented May 15, 2020

LGTM as well, thanks @timhoffm and Eric.

@seberg seberg merged commit 50ce0fc into numpy:master May 15, 2020
@timhoffm timhoffm deleted the doc-stack branch May 15, 2020 21:46
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.

4 participants
0