MCPcopy Create free account
hub / github.com/numpy/numpy / cutdeg

Method cutdeg

numpy/polynomial/_polybase.py:710–733  ·  view source on GitHub ↗

Truncate series to the given degree. Reduce the degree of the series to `deg` by discarding the high order terms. If `deg` is greater than the current degree a copy of the current series is returned. This can be useful in least squares where the coefficients of the h

(self, deg)

Source from the content-addressed store, hash-verified

708 return len(self) - 1
709
710 def cutdeg(self, deg):
711 """Truncate series to the given degree.
712
713 Reduce the degree of the series to `deg` by discarding the
714 high order terms. If `deg` is greater than the current degree a
715 copy of the current series is returned. This can be useful in least
716 squares where the coefficients of the high degree terms may be very
717 small.
718
719 .. versionadded:: 1.5.0
720
721 Parameters
722 ----------
723 deg : non-negative int
724 The series is reduced to degree `deg` by discarding the high
725 order terms. The value of `deg` must be a non-negative integer.
726
727 Returns
728 -------
729 new_series : series
730 New instance of series with reduced degree.
731
732 """
733 return self.truncate(deg + 1)
734
735 def trim(self, tol=0):
736 """Remove trailing coefficients

Callers 1

test_cutdegFunction · 0.80

Calls 1

truncateMethod · 0.95

Tested by 1

test_cutdegFunction · 0.64