Truncate series to length `size`. Reduce the series to length `size` by discarding the high degree terms. The value of `size` must be a positive integer. This can be useful in least squares where the coefficients of the high degree terms may be very small. P
(self, size)
| 756 | return self.__class__(coef, self.domain, self.window, self.symbol) |
| 757 | |
| 758 | def truncate(self, size): |
| 759 | """Truncate series to length `size`. |
| 760 | |
| 761 | Reduce the series to length `size` by discarding the high |
| 762 | degree terms. The value of `size` must be a positive integer. This |
| 763 | can be useful in least squares where the coefficients of the |
| 764 | high degree terms may be very small. |
| 765 | |
| 766 | Parameters |
| 767 | ---------- |
| 768 | size : positive int |
| 769 | The series is reduced to length `size` by discarding the high |
| 770 | degree terms. The value of `size` must be a positive integer. |
| 771 | |
| 772 | Returns |
| 773 | ------- |
| 774 | new_series : series |
| 775 | New instance of series with truncated coefficients. |
| 776 | |
| 777 | """ |
| 778 | isize = int(size) |
| 779 | if isize != size or isize < 1: |
| 780 | raise ValueError("size must be a positive integer") |
| 781 | if isize >= len(self.coef): |
| 782 | coef = self.coef |
| 783 | else: |
| 784 | coef = self.coef[:isize] |
| 785 | return self.__class__(coef, self.domain, self.window, self.symbol) |
| 786 | |
| 787 | def convert(self, domain=None, kind=None, window=None): |
| 788 | """Convert series to a different kind and/or domain and/or window. |
no outgoing calls