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

Method degree

numpy/polynomial/_polybase.py:670–702  ·  view source on GitHub ↗

The degree of the series. 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``: >>> np.polynomial.set_default_printsty

(self)

Source from the content-addressed store, hash-verified

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