8000 DOC: v/h/dstack docstr shouldn't imply deprecation by ahaldane · Pull Request #10057 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: v/h/dstack docstr shouldn't imply deprecation #10057

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
Nov 21, 2017

Conversation

ahaldane
Copy link
Member

This changes the v/h/dstack docstrings to more clearly describe what they do, and avoids implying they are deprecated.

This change was discussed on the mailing list here:
https://mail.python.org/pipermail/numpy-discussion/2017-November/077391.html

Take a sequence of arrays and stack them horizontally to make
a single array. Rebuild arrays divided by `hsplit`.
This is equivalent to concatenation along the second dimension for 2d and
3d arrays, or along the first dimension for 1d arrays. Rebuilds arrays
Copy link
Member

Choose a reason for hiding this comment

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

For number of dimensions > 2 it always stacks along second dimension. This seems to imply that it only works for arrays ndim <= 3.

This function continues to be supported for backward compatibility, but
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
function was added in NumPy 1.10.
This function is meant for use on arrays with 3 dimensions or less. The
Copy link
Member
@charris charris Nov 20, 2017

Choose a reason for hiding this comment

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

Not sure on the 3-D or less description here. It might not seem sensible for more dimensions, but there is no restriction. Maybe "makes most sense".

@eric-wieser
Copy link
Member

It might be worth mentioning that the 3d cases use h,v, and d as they might be referred to in a multichannel image. They don't correspond to the meanings expected of a matrix stack.

@ahaldane ahaldane force-pushed the vhdstack_docstring branch 4 times, most recently from 544fabc to 676881f Compare November 20, 2017 17:41
@ahaldane
Copy link
Member Author

Updated, to use makes most sense and to refer to multichannel images in dstack.

@rkern
Copy link
Member
rkern commented Nov 20, 2017

Thanks, I like this formulation better.

@eric-wieser
Copy link
Member

I think to justify "makes sense for 3d" in all the cases, you need to give the image example - not just for dstack. v and h only makes sense as describing axes 0 and 1 if axis 2 is the channel information.

@ahaldane ahaldane force-pushed the vhdstack_docstring branch 2 times, most recently from aa46a95 to 9875da6 Compare November 20, 2017 22:47
@ahaldane
Copy link
Member Author

Added the image example to all docstrings.

This function continues to be supported for backward compatibility, but
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
function was added in NumPy 1.10.
This function makes most sense for arrays with 3 dimensions or less. For
Copy link
Member

Choose a reason for hiding this comment

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

Should be "fewer", not "less"

Copy link
Member

Choose a reason for hiding this comment

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

No, "less" is correct and preferred in the "N items or less" construction.

http://languagelog.ldc.upenn.edu/nll/?p=2819

Copy link
Member
@eric-wieser eric-wieser Nov 21, 2017

Choose a reason for hiding this comment

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

The comments on the blog post seem pretty divided, but it's not worth arguing over here - a poll of my coworkers reveals this to be a divisive case!

Having said that, I think "up to 3 dimensions" would read better than either of those. But this patch is good enough without that.

This function makes most sense for arrays with 3 dimensions or less. For
instance, for image pixel-data with a height (first axis), width (second
axis), and possibly r/g/b channels (third axis). The functions
``np.concatenate``, ``np.stack`` and ``np.block`` provide more generalized
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to use single `s here so that these generate links?

@@ -183,23 +183,25 @@ def vstack(tup):
"""
Stack arrays in sequence vertically (row wise).

Take a sequence of arrays and stack them vertically to make a single
array. Rebuild arrays divided by `vsplit`.
This is equivalent to concatenation along the first axis after 1d arrays of
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 we settled on the form 1-D for these things, although a grep shows some leftovers.

Tuple containing arrays to be stacked. The arrays must have the same
shape along all but the first axis.
The arrays must have the same shape along all but the first axis.
1d arrays must have the same length.
Copy link
Member
@charris charris Nov 21, 2017

Choose a reason for hiding this comment

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

See above, etc.

@ahaldane
Copy link
Member Author

Fixed to use n-D.

@charris charris merged commit 14f8e56 into numpy:master Nov 21, 2017
@charris
Copy link
Member
charris commented Nov 21, 2017

Merged ignoring irrelevant appveyor tests. Thanks Allan.

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