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

Method degree

numpy/polynomial/_polybase.py:675–708  ·  view source on GitHub ↗

The degree of the series. .. versionadded:: 1.5.0 Returns ------- degree : int Degree of the series, one less than the number of coefficients. Examples -------- Create a polynomial object for ``1 + 7*x + 4*x**2``: >>> p

(self)

Source from the content-addressed store, hash-verified

673 return self.__class__(self.coef, self.domain, self.window, self.symbol)
674
675 def degree(self):
676 """The degree of the series.
677
678 .. versionadded:: 1.5.0
679
680 Returns
681 -------
682 degree : int
683 Degree of the series, one less than the number of coefficients.
684
685 Examples
686 --------
687
688 Create a polynomial object for ``1 + 7*x + 4*x**2``:
689
690 >>> poly = np.polynomial.Polynomial([1, 7, 4])
691 >>> print(poly)
692 1.0 + 7.0·x + 4.0·x²
693 >>> poly.degree()
694 2
695
696 Note that this method does not check for non-zero coefficients.
697 You must trim the polynomial to remove any trailing zeroes:
698
699 >>> poly = np.polynomial.Polynomial([1, 7, 0])
700 >>> print(poly)
701 1.0 + 7.0·x + 0.0·x²
702 >>> poly.degree()
703 2
704 >>> poly.trim().degree()
705 1
706
707 """
708 return len(self) - 1
709
710 def cutdeg(self, deg):
711 """Truncate series to the given degree.

Callers 4

test_fromrootsFunction · 0.80
test_fitFunction · 0.80
test_degreeFunction · 0.80
test_dimensionsMethod · 0.80

Calls

no outgoing calls

Tested by 4

test_fromrootsFunction · 0.64
test_fitFunction · 0.64
test_degreeFunction · 0.64
test_dimensionsMethod · 0.64