SciPy

numpy.polynomial.polyutils.as_series

numpy.polynomial.polyutils.as_series(alist, trim=True)[source]

Return argument as a list of 1-d arrays.

The returned list contains array(s) of dtype double, complex double, or object. A 1-d argument of shape (N,) is parsed into N arrays of size one; a 2-d argument of shape (M,N) is parsed into M arrays of size N (i.e., is “parsed by row”); and a higher dimensional array raises a Value Error if it is not first reshaped into either a 1-d or 2-d array.

Parameters:
alist : array_like

A 1- or 2-d array_like

trim : boolean, optional

When True, trailing zeros are removed from the inputs. When False, the inputs are passed through intact.

Returns:
[a1, a2,…] : list of 1-D arrays

A copy of the input data as a list of 1-d arrays.

Raises:
ValueError

Raised when as_series cannot convert its input to 1-d arrays, or at least one of the resulting arrays is empty.

Examples

>>> from numpy.polynomial import polyutils as pu
>>> a = np.arange(4)
>>> pu.as_series(a)
[array([0.]), array([1.]), array([2.]), array([3.])]
>>> b = np.arange(6).reshape((2,3))
>>> pu.as_series(b)
[array([0., 1., 2.]), array([3., 4., 5.])]
>>> pu.as_series((1, np.arange(3), np.arange(2, dtype=np.float16)))
[array([1.]), array([0., 1., 2.]), array([0., 1.])]
>>> pu.as_series([2, [1.1, 0.]])
[array([2.]), array([1.1])]
>>> pu.as_series([2, [1.1, 0.]], trim=False)
[array([2.]), array([1.1, 0. ])]

Previous topic

numpy.polynomial.polyutils.PolyBase

Next topic

numpy.polynomial.polyutils.trimseq