MCPcopy Index your code
hub / github.com/numpy/numpy / as_series

Function as_series

numpy/polynomial/polyutils.py:63–141  ·  view source on GitHub ↗

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.,

(alist, trim=True)

Source from the content-addressed store, hash-verified

61
62
63def as_series(alist, trim=True):
64 """
65 Return argument as a list of 1-d arrays.
66
67 The returned list contains array(s) of dtype double, complex double, or
68 object. A 1-d argument of shape ``(N,)`` is parsed into ``N`` arrays of
69 size one; a 2-d argument of shape ``(M,N)`` is parsed into ``M`` arrays
70 of size ``N`` (i.e., is "parsed by row"); and a higher dimensional array
71 raises a Value Error if it is not first reshaped into either a 1-d or 2-d
72 array.
73
74 Parameters
75 ----------
76 alist : array_like
77 A 1- or 2-d array_like
78 trim : boolean, optional
79 When True, trailing zeros are removed from the inputs.
80 When False, the inputs are passed through intact.
81
82 Returns
83 -------
84 [a1, a2,...] : list of 1-D arrays
85 A copy of the input data as a list of 1-d arrays.
86
87 Raises
88 ------
89 ValueError
90 Raised when `as_series` cannot convert its input to 1-d arrays, or at
91 least one of the resulting arrays is empty.
92
93 Examples
94 --------
95 >>> import numpy as np
96 >>> from numpy.polynomial import polyutils as pu
97 >>> a = np.arange(4)
98 >>> pu.as_series(a)
99 [array([0.]), array([1.]), array([2.]), array([3.])]
100 >>> b = np.arange(6).reshape((2,3))
101 >>> pu.as_series(b)
102 [array([0., 1., 2.]), array([3., 4., 5.])]
103
104 >>> pu.as_series((1, np.arange(3), np.arange(2, dtype=np.float16)))
105 [array([1.]), array([0., 1., 2.]), array([0., 1.])]
106
107 >>> pu.as_series([2, [1.1, 0.]])
108 [array([2.]), array([1.1])]
109
110 >>> pu.as_series([2, [1.1, 0.]], trim=False)
111 [array([2.]), array([1.1, 0. ])]
112
113 """
114 arrays = [np.array(a, ndmin=1, copy=None) for a in alist]
115 for a in arrays:
116 if a.size == 0:
117 raise ValueError("Coefficient array is empty")
118 if a.ndim != 1:
119 raise ValueError("Coefficient array is not 1-d")
120 if trim:

Callers 7

trimcoefFunction · 0.85
getdomainFunction · 0.85
_fromrootsFunction · 0.85
_divFunction · 0.85
_addFunction · 0.85
_subFunction · 0.85
_powFunction · 0.85

Calls 2

trimseqFunction · 0.85
copyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…