8000 Merge pull request #10057 from ahaldane/vhdstack_docstring · numpy/numpy@14f8e56 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14f8e56

Browse files
authored
Merge pull request #10057 from ahaldane/vhdstack_docstring
DOC: v/h/dstack docstr shouldn't imply deprecation
2 parents b6044d8 + e1811e1 commit 14f8e56

File tree

2 files changed

+30
-39
lines changed

2 files changed

+30
-39
lines changed

numpy/core/shape_base.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,25 @@ def vstack(tup):
183183
"""
184184
Stack arrays in sequence vertically (row wise).
185185
186-
Take a sequence of arrays and stack them vertically to make a single
187-
array. Rebuild arrays divided by `vsplit`.
186+
This is equivalent to concatenation along the first axis after 1-D arrays
187+
of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by
188+
`vsplit`.
188189
189-
This function continues to be supported for backward compatibility, but
190-
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
191-
function was added in NumPy 1.10.
190+
This function makes most sense for arrays with up to 3 dimensions. For
191+
instance, for pixel-data with a height (first axis), width (second axis),
192+
and r/g/b channels (third axis). The functions `concatenate`, `stack` and
193+
`block` provide more general stacking and concatenation operations.
192194
193195
Parameters
194196
----------
195197
tup : sequence of ndarrays
196-
Tuple containing arrays to be stacked. The arrays must have the same
197-
shape along all but the first axis.
198+
The arrays must have the same shape along all but the first axis.
199+
1-D arrays must have the same length.
198200
199201
Returns
200202
-------
201203
stacked : ndarray
202-
The array formed by stacking the given arrays.
204+
The array formed by stacking the given arrays, will be at least 2-D.
203205
204206
See Also
205207
--------
@@ -210,11 +212,6 @@ def vstack(tup):
210212
vsplit : Split array into a list of multiple sub-arrays vertically.
211213
block : Assemble arrays from blocks.
212214
213-
Notes
214-
-----
215-
Equivalent to ``np.concatenate(tup, axis=0)`` if `tup` contains arrays that
216-
are at least 2-dimensional.
217-
218215
Examples
219216
--------
220217
>>> a = np.array([1, 2, 3])
@@ -240,17 +237,20 @@ def hstack(tup):
240237
"""
241238
Stack arrays in sequence horizontally (column wise).
242239
243-
Take a sequence of arrays and stack them horizontally to make
244-
a single array. Rebuild arrays divided by `hsplit`.
240+
This is equivalent to concatenation along the second axis, except for 1-D
241+
arrays where it concatenates along the first axis. Rebuilds arrays divided
242+
by `hsplit`.
245243
246-
This function continues to be supported for backward compatibility, but
247-
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
248-
function was added in NumPy 1.10.
244+
This function makes most sense for arrays with up to 3 dimensions. For
245+
instance, for pixel-data with a height (first axis), width (second axis),
246+
and r/g/b channels (third axis). The functions `concatenate`, `stack` and
247+
`block` provide more general stacking and concatenation operations.
249248
250249
Parameters
251250
----------
252251
tup : sequence of ndarrays
253-
All arrays must have the same shape along all but the second axis.
252< 8000 span class="diff-text-marker">+
The arrays must have the same shape along all but the second axis,
253+
except 1-D arrays which can be any length.
254254
255255
Returns
256256
-------
@@ -266,11 +266,6 @@ def hstack(tup):
266266
hsplit : Split array along second axis.
267267
block : Assemble arrays from blocks.
268268
269-
Notes
270-
-----
271-
Equivalent to ``np.concatenate(tup, axis=1)`` if `tup` contains arrays that
272-
are at least 2-dimensional.
273-
274269
Examples
275270
--------
276271
>>> a = np.array((1,2,3))

numpy/lib/shape_base.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,25 +354,26 @@ def dstack(tup):
354354
"""
355355
Stack arrays in sequence depth wise (along third axis).
356356
357-
Takes a sequence of arrays and stack them along the third axis
358-
to make a single array. Rebuilds arrays divided by `dsplit`.
359-
This is a simple way to stack 2D arrays (images) into a single
360-
3D array for processing.
357+
This is equivalent to concatenation along the third axis after 2-D arrays
358+
of shape `(M,N)` have been reshaped to `(M,N,1)` and 1-D arrays of shape
359+
`(N,)` have been reshaped to `(1,N,1)`. Rebuilds arrays divided by
360+
`dsplit`.
361361
362-
This function continues to be supported for backward compatibility, but
363-
you should prefer ``np.concatenate`` or ``np.stack``. The ``np.stack``
364-
function was added in NumPy 1.10.
362+
This function makes most sense for arrays with up to 3 dimensions. For
363+
instance, for pixel-data with a height (first axis), width (second axis),
364+
and r/g/b channels (third axis). The functions `concatenate`, `stack` and
365+
`block` provide more general stacking and concatenation operations.
365366
366367
Parameters
367368
----------
368369
tup : sequence of arrays
369-
Arrays to stack. All of them must have the same shape along all
370-
but the third axis.
370+
The arrays must have the same shape along all but the third axis.
371+
1-D or 2-D arrays must have the same shape.
371372
372373
Returns
373374
-------
374375
stacked : ndarray
375-
The array formed by stacking the given arrays.
376+
The array formed by stacking the given arrays, will be at least 3-D.
376377
377378
See Also
378379
--------
@@ -382,11 +383,6 @@ def dstack(tup):
382383
concatenate : Join a sequence of arrays along an existing axis.
383384
dsplit : Split array along third axis.
384385
385-
Notes
386-
-----
387-
Equivalent to ``np.concatenate(tup, axis=2)`` if `tup` contains arrays that
388-
are at least 3-dimensional.
389-
390386
Examples
391387
--------
392388
>>> a = np.array((1,2,3))

0 commit comments

Comments
 (0)
0