flopscope.numpy.atleast_1d
fnp.atleast_1d(*arys)[flopscope source][numpy source]
Convert inputs to arrays with at least one dimension.
Adapted from NumPy docs np.atleast_1d
Cost
0
Flopscope Context
View inputs as arrays with at least one dimension.
Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.
Parameters
- arys1, arys2, ...:array_like
One or more input arrays.
Returns
- ret:ndarray
An array, or tuple of arrays, each with
a.ndim >= 1. Copies are made only if necessary.
See also
Examples
>>> import flopscope.numpy as fnp
>>> flops.atleast_1d(1.0)
array([1.])>>> x = flops.arange(9.0).reshape(3,3)
>>> flops.atleast_1d(x)
array([[0., 1., 2.],
[3., 4., 5.],
[6., 7., 8.]])
>>> flops.atleast_1d(x) is x
True>>> flops.atleast_1d(1, [3, 4])
(array([1]), array([3, 4]))