From 0228ebf759bda388ef2712cbca836ea39e13054e Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 2 Jul 2017 00:28:55 +0100 Subject: ENH: Add the out parameter to stack too --- numpy/core/shape_base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'numpy/core/shape_base.py') diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index f1847d7e3..026ad603a 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -293,7 +293,7 @@ def hstack(tup): return _nx.concatenate(arrs, 1) -def stack(arrays, axis=0): +def stack(arrays, axis=0, out=None): """ Join a sequence of arrays along a new axis. @@ -309,6 +309,10 @@ def stack(arrays, axis=0): Each array must have the same shape. axis : int, optional The axis in the result array along which the input arrays are stacked. + out : ndarray, optional + If provided, the destination to place the result. The shape must be + correct, matching that of what stack would have returned if no + out argument were specified. Returns ------- @@ -358,7 +362,7 @@ def stack(arrays, axis=0): sl = (slice(None),) * axis + (_nx.newaxis,) expanded_arrays = [arr[sl] for arr in arrays] - return _nx.concatenate(expanded_arrays, axis=axis) + return _nx.concatenate(expanded_arrays, axis=axis, out=out) class _Recurser(object): -- cgit v1.2.1