nums.numpy.atleast_1d

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

Convert inputs to arrays with at least one dimension.

This docstring was copied from numpy.atleast_1d.

Some inconsistencies with the NumS version may exist.

Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.

Parameters
Returns

ret – An array, or list of arrays, each with a.ndim >= 1. Copies are made only if necessary.

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_1d(1.0).get()  
array([1.])
>>> x = nps.arange(9.0).reshape(3,3)  
>>> nps.atleast_1d(x).get()  
array([[0., 1., 2.],
       [3., 4., 5.],
       [6., 7., 8.]])
>>> [a.get() for a in nps.atleast_1d(1, [3, 4])]  
[array([1]), array([3, 4])]