nums.numpy.atleast_3d
-
nums.numpy.
atleast_3d
(*arys)[source] View inputs as arrays with at least three dimensions.
This docstring was copied from numpy.atleast_3d.
Some inconsistencies with the NumS version may exist.
- Parameters
arys1 (BlockArray) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
arys2 (BlockArray) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
.. (BlockArray) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
- Returns
res1, res2, … – An array, or list of arrays, each with
a.ndim >= 3
. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape(N,)
becomes a view of shape(1, N, 1)
, and a 2-D array of shape(M, N)
becomes a view of shape(M, N, 1)
.- Return type
See also
Examples
The doctests shown below are copied from NumPy. They won’t show the correct result until you operate
get()
.>>> nps.atleast_3d(3.0).get() array([[[3.]]])
>>> x = nps.arange(3.0) >>> nps.atleast_3d(x).shape (1, 3, 1)
>>> x = nps.arange(12.0).reshape(4,3) >>> nps.atleast_3d(x).shape (4, 3, 1)
>>> for arr in nps.atleast_3d([1, 2], [[1, 2]], [[[1, 2]]]): ... print(arr.get(), arr.shape) ... [[[1] [2]]] (1, 2, 1) [[[1] [2]]] (1, 2, 1) [[[1 2]]] (1, 1, 2)