Python numpy.core.numeric.shape() Examples
The following are 30
code examples of numpy.core.numeric.shape().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy.core.numeric
, or try the search function
.
Example #1
Source File: shape_base.py From pySINDy with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #2
Source File: shape_base.py From twitter-stock-recommendation with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #3
Source File: shape_base.py From lambda-packs with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #4
Source File: shape_base.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #5
Source File: shape_base.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if len(_nx.shape(sub_arys[i])) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #6
Source File: shape_base.py From keras-lambda with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if len(_nx.shape(sub_arys[i])) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #7
Source File: shape_base.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #8
Source File: shape_base.py From vnpy_crypto with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #9
Source File: shape_base.py From coffeegrindsize with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #10
Source File: shape_base.py From Computable with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if len(_nx.shape(sub_arys[i])) == 0: sub_arys[i] = _nx.array([]) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.array([]) return sub_arys
Example #11
Source File: shape_base.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #12
Source File: shape_base.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #13
Source File: shape_base.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #14
Source File: shape_base.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #15
Source File: shape_base.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #16
Source File: shape_base.py From ImageFusion with MIT License | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if len(_nx.shape(sub_arys[i])) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #17
Source File: shape_base.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if len(_nx.shape(sub_arys[i])) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #18
Source File: shape_base.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #19
Source File: shape_base.py From recruit with Apache License 2.0 | 5 votes |
def _replace_zero_by_x_arrays(sub_arys): for i in range(len(sub_arys)): if _nx.ndim(sub_arys[i]) == 0: sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) elif _nx.sometrue(_nx.equal(_nx.shape(sub_arys[i]), 0)): sub_arys[i] = _nx.empty(0, dtype=sub_arys[i].dtype) return sub_arys
Example #20
Source File: shape_base.py From ImageFusion with MIT License | 4 votes |
def expand_dims(a, axis): """ Expand the shape of an array. Insert a new axis, corresponding to a given position in the array shape. Parameters ---------- a : array_like Input array. axis : int Position (amongst axes) where new axis is to be inserted. Returns ------- res : ndarray Output array. The number of dimensions is one greater than that of the input array. See Also -------- doc.indexing, atleast_1d, atleast_2d, atleast_3d Examples -------- >>> x = np.array([1,2]) >>> x.shape (2,) The following is equivalent to ``x[np.newaxis,:]`` or ``x[np.newaxis]``: >>> y = np.expand_dims(x, axis=0) >>> y array([[1, 2]]) >>> y.shape (1, 2) >>> y = np.expand_dims(x, axis=1) # Equivalent to x[:,newaxis] >>> y array([[1], [2]]) >>> y.shape (2, 1) Note that some examples may use ``None`` instead of ``np.newaxis``. These are the same objects: >>> np.newaxis is None True """ a = asarray(a) shape = a.shape if axis < 0: axis = axis + len(shape) + 1 return a.reshape(shape[:axis] + (1,) + shape[axis:])
Example #21
Source File: shape_base.py From keras-lambda with MIT License | 4 votes |
def dstack(tup): """ Stack arrays in sequence depth wise (along third axis). Takes a sequence of arrays and stack them along the third axis to make a single array. Rebuilds arrays divided by `dsplit`. This is a simple way to stack 2D arrays (images) into a single 3D array for processing. Parameters ---------- tup : sequence of arrays Arrays to stack. All of them must have the same shape along all but the third axis. Returns ------- stacked : ndarray The array formed by stacking the given arrays. See Also -------- stack : Join a sequence of arrays along a new axis. vstack : Stack along first axis. hstack : Stack along second axis. concatenate : Join a sequence of arrays along an existing axis. dsplit : Split array along third axis. Notes ----- Equivalent to ``np.concatenate(tup, axis=2)``. Examples -------- >>> a = np.array((1,2,3)) >>> b = np.array((2,3,4)) >>> np.dstack((a,b)) array([[[1, 2], [2, 3], [3, 4]]]) >>> a = np.array([[1],[2],[3]]) >>> b = np.array([[2],[3],[4]]) >>> np.dstack((a,b)) array([[[1, 2]], [[2, 3]], [[3, 4]]]) """ return _nx.concatenate([atleast_3d(_m) for _m in tup], 2)
Example #22
Source File: shape_base.py From recruit with Apache License 2.0 | 4 votes |
def dstack(tup): """ Stack arrays in sequence depth wise (along third axis). This is equivalent to concatenation along the third axis after 2-D arrays of shape `(M,N)` have been reshaped to `(M,N,1)` and 1-D arrays of shape `(N,)` have been reshaped to `(1,N,1)`. Rebuilds arrays divided by `dsplit`. This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions `concatenate`, `stack` and `block` provide more general stacking and concatenation operations. Parameters ---------- tup : sequence of arrays The arrays must have the same shape along all but the third axis. 1-D or 2-D arrays must have the same shape. Returns ------- stacked : ndarray The array formed by stacking the given arrays, will be at least 3-D. See Also -------- stack : Join a sequence of arrays along a new axis. vstack : Stack along first axis. hstack : Stack along second axis. concatenate : Join a sequence of arrays along an existing axis. dsplit : Split array along third axis. Examples -------- >>> a = np.array((1,2,3)) >>> b = np.array((2,3,4)) >>> np.dstack((a,b)) array([[[1, 2], [2, 3], [3, 4]]]) >>> a = np.array([[1],[2],[3]]) >>> b = np.array([[2],[3],[4]]) >>> np.dstack((a,b)) array([[[1, 2]], [[2, 3]], [[3, 4]]]) """ _warn_for_nonsequence(tup) return _nx.concatenate([atleast_3d(_m) for _m in tup], 2)
Example #23
Source File: shape_base.py From mxnet-lambda with Apache License 2.0 | 4 votes |
def dstack(tup): """ Stack arrays in sequence depth wise (along third axis). Takes a sequence of arrays and stack them along the third axis to make a single array. Rebuilds arrays divided by `dsplit`. This is a simple way to stack 2D arrays (images) into a single 3D array for processing. 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. Parameters ---------- tup : sequence of arrays Arrays to stack. All of them must have the same shape along all but the third axis. Returns ------- stacked : ndarray The array formed by stacking the given arrays. See Also -------- stack : Join a sequence of arrays along a new axis. vstack : Stack along first axis. hstack : Stack along second axis. concatenate : Join a sequence of arrays along an existing axis. dsplit : Split array along third axis. Notes ----- Equivalent to ``np.concatenate(tup, axis=2)`` if `tup` contains arrays that are at least 3-dimensional. Examples -------- >>> a = np.array((1,2,3)) >>> b = np.array((2,3,4)) >>> np.dstack((a,b)) array([[[1, 2], [2, 3], [3, 4]]]) >>> a = np.array([[1],[2],[3]]) >>> b = np.array([[2],[3],[4]]) >>> np.dstack((a,b)) array([[[1, 2]], [[2, 3]], [[3, 4]]]) """ return _nx.concatenate([atleast_3d(_m) for _m in tup], 2)
Example #24
Source File: shape_base.py From keras-lambda with MIT License | 4 votes |
def dsplit(ary, indices_or_sections): """ Split array into multiple sub-arrays along the 3rd axis (depth). Please refer to the `split` documentation. `dsplit` is equivalent to `split` with ``axis=2``, the array is always split along the third axis provided the array dimension is greater than or equal to 3. See Also -------- split : Split an array into multiple sub-arrays of equal size. Examples -------- >>> x = np.arange(16.0).reshape(2, 2, 4) >>> x array([[[ 0., 1., 2., 3.], [ 4., 5., 6., 7.]], [[ 8., 9., 10., 11.], [ 12., 13., 14., 15.]]]) >>> np.dsplit(x, 2) [array([[[ 0., 1.], [ 4., 5.]], [[ 8., 9.], [ 12., 13.]]]), array([[[ 2., 3.], [ 6., 7.]], [[ 10., 11.], [ 14., 15.]]])] >>> np.dsplit(x, np.array([3, 6])) [array([[[ 0., 1., 2.], [ 4., 5., 6.]], [[ 8., 9., 10.], [ 12., 13., 14.]]]), array([[[ 3.], [ 7.]], [[ 11.], [ 15.]]]), array([], dtype=float64)] """ if len(_nx.shape(ary)) < 3: raise ValueError('dsplit only works on arrays of 3 or more dimensions') return split(ary, indices_or_sections, 2)
Example #25
Source File: shape_base.py From mxnet-lambda with Apache License 2.0 | 4 votes |
def array_split(ary, indices_or_sections, axis=0): """ Split an array into multiple sub-arrays. Please refer to the ``split`` documentation. The only difference between these functions is that ``array_split`` allows `indices_or_sections` to be an integer that does *not* equally divide the axis. See Also -------- split : Split array into multiple sub-arrays of equal size. Examples -------- >>> x = np.arange(8.0) >>> np.array_split(x, 3) [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7.])] """ try: Ntotal = ary.shape[axis] except AttributeError: Ntotal = len(ary) try: # handle scalar case. Nsections = len(indices_or_sections) + 1 div_points = [0] + list(indices_or_sections) + [Ntotal] except TypeError: # indices_or_sections is a scalar, not an array. Nsections = int(indices_or_sections) if Nsections <= 0: raise ValueError('number sections must be larger than 0.') Neach_section, extras = divmod(Ntotal, Nsections) section_sizes = ([0] + extras * [Neach_section+1] + (Nsections-extras) * [Neach_section]) div_points = _nx.array(section_sizes).cumsum() sub_arys = [] sary = _nx.swapaxes(ary, axis, 0) for i in range(Nsections): st = div_points[i] end = div_points[i + 1] sub_arys.append(_nx.swapaxes(sary[st:end], axis, 0)) return sub_arys
Example #26
Source File: shape_base.py From ImageFusion with MIT License | 4 votes |
def array_split(ary, indices_or_sections, axis=0): """ Split an array into multiple sub-arrays. Please refer to the ``split`` documentation. The only difference between these functions is that ``array_split`` allows `indices_or_sections` to be an integer that does *not* equally divide the axis. See Also -------- split : Split array into multiple sub-arrays of equal size. Examples -------- >>> x = np.arange(8.0) >>> np.array_split(x, 3) [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7.])] """ try: Ntotal = ary.shape[axis] except AttributeError: Ntotal = len(ary) try: # handle scalar case. Nsections = len(indices_or_sections) + 1 div_points = [0] + list(indices_or_sections) + [Ntotal] except TypeError: # indices_or_sections is a scalar, not an array. Nsections = int(indices_or_sections) if Nsections <= 0: raise ValueError('number sections must be larger than 0.') Neach_section, extras = divmod(Ntotal, Nsections) section_sizes = ([0] + extras * [Neach_section+1] + (Nsections-extras) * [Neach_section]) div_points = _nx.array(section_sizes).cumsum() sub_arys = [] sary = _nx.swapaxes(ary, axis, 0) for i in range(Nsections): st = div_points[i] end = div_points[i + 1] sub_arys.append(_nx.swapaxes(sary[st:end], axis, 0)) # This "kludge" was introduced here to replace arrays shaped (0, 10) # or similar with an array shaped (0,). # There seems no need for this, so give a FutureWarning to remove later. if sub_arys[-1].size == 0 and sub_arys[-1].ndim != 1: warnings.warn("in the future np.array_split will retain the shape of " "arrays with a zero size, instead of replacing them by " "`array([])`, which always has a shape of (0,).", FutureWarning) sub_arys = _replace_zero_by_x_arrays(sub_arys) return sub_arys
Example #27
Source File: shape_base.py From keras-lambda with MIT License | 4 votes |
def array_split(ary, indices_or_sections, axis=0): """ Split an array into multiple sub-arrays. Please refer to the ``split`` documentation. The only difference between these functions is that ``array_split`` allows `indices_or_sections` to be an integer that does *not* equally divide the axis. See Also -------- split : Split array into multiple sub-arrays of equal size. Examples -------- >>> x = np.arange(8.0) >>> np.array_split(x, 3) [array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7.])] """ try: Ntotal = ary.shape[axis] except AttributeError: Ntotal = len(ary) try: # handle scalar case. Nsections = len(indices_or_sections) + 1 div_points = [0] + list(indices_or_sections) + [Ntotal] except TypeError: # indices_or_sections is a scalar, not an array. Nsections = int(indices_or_sections) if Nsections <= 0: raise ValueError('number sections must be larger than 0.') Neach_section, extras = divmod(Ntotal, Nsections) section_sizes = ([0] + extras * [Neach_section+1] + (Nsections-extras) * [Neach_section]) div_points = _nx.array(section_sizes).cumsum() sub_arys = [] sary = _nx.swapaxes(ary, axis, 0) for i in range(Nsections): st = div_points[i] end = div_points[i + 1] sub_arys.append(_nx.swapaxes(sary[st:end], axis, 0)) return sub_arys
Example #28
Source File: shape_base.py From ImageFusion with MIT License | 4 votes |
def hsplit(ary, indices_or_sections): """ Split an array into multiple sub-arrays horizontally (column-wise). Please refer to the `split` documentation. `hsplit` is equivalent to `split` with ``axis=1``, the array is always split along the second axis regardless of the array dimension. See Also -------- split : Split an array into multiple sub-arrays of equal size. Examples -------- >>> x = np.arange(16.0).reshape(4, 4) >>> x array([[ 0., 1., 2., 3.], [ 4., 5., 6., 7.], [ 8., 9., 10., 11.], [ 12., 13., 14., 15.]]) >>> np.hsplit(x, 2) [array([[ 0., 1.], [ 4., 5.], [ 8., 9.], [ 12., 13.]]), array([[ 2., 3.], [ 6., 7.], [ 10., 11.], [ 14., 15.]])] >>> np.hsplit(x, np.array([3, 6])) [array([[ 0., 1., 2.], [ 4., 5., 6.], [ 8., 9., 10.], [ 12., 13., 14.]]), array([[ 3.], [ 7.], [ 11.], [ 15.]]), array([], dtype=float64)] With a higher dimensional array the split is still along the second axis. >>> x = np.arange(8.0).reshape(2, 2, 2) >>> x array([[[ 0., 1.], [ 2., 3.]], [[ 4., 5.], [ 6., 7.]]]) >>> np.hsplit(x, 2) [array([[[ 0., 1.]], [[ 4., 5.]]]), array([[[ 2., 3.]], [[ 6., 7.]]])] """ if len(_nx.shape(ary)) == 0: raise ValueError('hsplit only works on arrays of 1 or more dimensions') if len(ary.shape) > 1: return split(ary, indices_or_sections, 1) else: return split(ary, indices_or_sections, 0)
Example #29
Source File: shape_base.py From ImageFusion with MIT License | 4 votes |
def dsplit(ary, indices_or_sections): """ Split array into multiple sub-arrays along the 3rd axis (depth). Please refer to the `split` documentation. `dsplit` is equivalent to `split` with ``axis=2``, the array is always split along the third axis provided the array dimension is greater than or equal to 3. See Also -------- split : Split an array into multiple sub-arrays of equal size. Examples -------- >>> x = np.arange(16.0).reshape(2, 2, 4) >>> x array([[[ 0., 1., 2., 3.], [ 4., 5., 6., 7.]], [[ 8., 9., 10., 11.], [ 12., 13., 14., 15.]]]) >>> np.dsplit(x, 2) [array([[[ 0., 1.], [ 4., 5.]], [[ 8., 9.], [ 12., 13.]]]), array([[[ 2., 3.], [ 6., 7.]], [[ 10., 11.], [ 14., 15.]]])] >>> np.dsplit(x, np.array([3, 6])) [array([[[ 0., 1., 2.], [ 4., 5., 6.]], [[ 8., 9., 10.], [ 12., 13., 14.]]]), array([[[ 3.], [ 7.]], [[ 11.], [ 15.]]]), array([], dtype=float64)] """ if len(_nx.shape(ary)) < 3: raise ValueError('dsplit only works on arrays of 3 or more dimensions') return split(ary, indices_or_sections, 2)
Example #30
Source File: shape_base.py From ImageFusion with MIT License | 4 votes |
def dstack(tup): """ Stack arrays in sequence depth wise (along third axis). Takes a sequence of arrays and stack them along the third axis to make a single array. Rebuilds arrays divided by `dsplit`. This is a simple way to stack 2D arrays (images) into a single 3D array for processing. Parameters ---------- tup : sequence of arrays Arrays to stack. All of them must have the same shape along all but the third axis. Returns ------- stacked : ndarray The array formed by stacking the given arrays. See Also -------- vstack : Stack along first axis. hstack : Stack along second axis. concatenate : Join arrays. dsplit : Split array along third axis. Notes ----- Equivalent to ``np.concatenate(tup, axis=2)``. Examples -------- >>> a = np.array((1,2,3)) >>> b = np.array((2,3,4)) >>> np.dstack((a,b)) array([[[1, 2], [2, 3], [3, 4]]]) >>> a = np.array([[1],[2],[3]]) >>> b = np.array([[2],[3],[4]]) >>> np.dstack((a,b)) array([[[1, 2]], [[2, 3]], [[3, 4]]]) """ return _nx.concatenate([atleast_3d(_m) for _m in tup], 2)