nums.numpy.atleast_2d

nums.numpy.atleast_2d(*arys)[source]

View inputs as arrays with at least two dimensions.

This docstring was copied from numpy.atleast_2d.

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 two or more dimensions are preserved.

  • arys2 (BlockArray) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.

  • .. (BlockArray) – One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved.

Returns

res, res2, … – An array, or list of arrays, each with a.ndim >= 2. Copies are avoided where possible, and views with two or more dimensions are returned.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.atleast_2d(3.0).get()  
array([[3.]])
>>> x = nps.arange(3.0)  
>>> nps.atleast_2d(x).get()  
array([[0., 1., 2.]])
>>> [a.get() for a in nps.atleast_2d(1, [1, 2], [[1, 3]])]  
[array([[1]]), array([[1, 2]]), array([[1, 2]])]