MCPcopy
hub / github.com/numpy/numpy / vstack

Function vstack

numpy/_core/shape_base.py:219–290  ·  view source on GitHub ↗

Stack arrays in sequence vertically (row wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by `vsplit`. This function makes most sense for arrays with up to 3 dimensions. For

(tup, *, dtype=None, casting="same_kind")

Source from the content-addressed store, hash-verified

217
218@array_function_dispatch(_vhstack_dispatcher)
219def vstack(tup, *, dtype=None, casting="same_kind"):
220 """
221 Stack arrays in sequence vertically (row wise).
222
223 This is equivalent to concatenation along the first axis after 1-D arrays
224 of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by
225 `vsplit`.
226
227 This function makes most sense for arrays with up to 3 dimensions. For
228 instance, for pixel-data with a height (first axis), width (second axis),
229 and r/g/b channels (third axis). The functions `concatenate`, `stack` and
230 `block` provide more general stacking and concatenation operations.
231
232 Parameters
233 ----------
234 tup : sequence of ndarrays
235 The arrays must have the same shape along all but the first axis.
236 1-D arrays must have the same length. In the case of a single
237 array_like input, it will be treated as a sequence of arrays; i.e.,
238 each element along the zeroth axis is treated as a separate array.
239
240 dtype : str or dtype
241 If provided, the destination array will have this dtype. Cannot be
242 provided together with `out`.
243
244 .. versionadded:: 1.24
245
246 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
247 Controls what kind of data casting may occur. Defaults to 'same_kind'.
248
249 .. versionadded:: 1.24
250
251 Returns
252 -------
253 stacked : ndarray
254 The array formed by stacking the given arrays, will be at least 2-D.
255
256 See Also
257 --------
258 concatenate : Join a sequence of arrays along an existing axis.
259 stack : Join a sequence of arrays along a new axis.
260 block : Assemble an nd-array from nested lists of blocks.
261 hstack : Stack arrays in sequence horizontally (column wise).
262 dstack : Stack arrays in sequence depth wise (along third axis).
263 column_stack : Stack 1-D arrays as columns into a 2-D array.
264 vsplit : Split an array into multiple sub-arrays vertically (row-wise).
265 unstack : Split an array into a tuple of sub-arrays along an axis.
266
267 Examples
268 --------
269 >>> import numpy as np
270 >>> a = np.array([1, 2, 3])
271 >>> b = np.array([4, 5, 6])
272 >>> np.vstack((a,b))
273 array([[1, 2, 3],
274 [4, 5, 6]])
275
276 >>> a = np.array([[1], [2], [3]])

Callers 8

test_0D_arrayMethod · 0.90
test_1D_arrayMethod · 0.90
test_2D_arrayMethod · 0.90
test_2D_array2Method · 0.90
test_generatorMethod · 0.90
test_stack_1dMethod · 0.85
test_stack_masksMethod · 0.85

Calls 1

atleast_2dFunction · 0.85

Tested by 8

test_0D_arrayMethod · 0.72
test_1D_arrayMethod · 0.72
test_2D_arrayMethod · 0.72
test_2D_array2Method · 0.72
test_generatorMethod · 0.72
test_stack_1dMethod · 0.68
test_stack_masksMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…