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

Function trimseq

numpy/polynomial/polyutils.py:34–60  ·  view source on GitHub ↗

Remove small Poly series coefficients. Parameters ---------- seq : sequence Sequence of Poly series coefficients. Returns ------- series : sequence Subsequence with trailing zeros removed. If the resulting sequence would be empty, return the first el

(seq)

Source from the content-addressed store, hash-verified

32# Helper functions to convert inputs to 1-D arrays
33#
34def trimseq(seq):
35 """Remove small Poly series coefficients.
36
37 Parameters
38 ----------
39 seq : sequence
40 Sequence of Poly series coefficients.
41
42 Returns
43 -------
44 series : sequence
45 Subsequence with trailing zeros removed. If the resulting sequence
46 would be empty, return the first element. The returned sequence may
47 or may not be a view.
48
49 Notes
50 -----
51 Do not lose the type info if the sequence contains unknown objects.
52
53 """
54 if len(seq) == 0 or seq[-1] != 0:
55 return seq
56 else:
57 for i in range(len(seq) - 1, -1, -1):
58 if seq[i] != 0:
59 break
60 return seq[:i + 1]
61
62
63def as_series(alist, trim=True):

Callers 4

as_seriesFunction · 0.85
_divFunction · 0.85
_addFunction · 0.85
_subFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…