atmost_1d#

m4opt.utils.numpy.atmost_1d(a)[source] [edit on github]#

Force an array-like object to have no more than 1 dimension.

Examples

>>> from m4opt.utils.numpy import atmost_1d
>>> atmost_1d([[1, 2], [3, 4]])
array([1, 2, 3, 4])
>>> atmost_1d([1, 2, 3, 4])
array([1, 2, 3, 4])
>>> atmost_1d([])
array([], dtype=float64)
>>> atmost_1d(1)
1

See also

numpy.atleast_1d