diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 7b4d0a9b664..33f45813027 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -2671,13 +2671,25 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): 1 sage: poly.degree(S.1) 2 + + Ensure that :issue:`37603` is fixed:: + + sage: R. = QQ[] + sage: f = x + y + 1 + sage: type(f.degree()) + + sage: type(f.degree(x)) + + sage: type(f.degree(y)) + + """ cdef ring *r = self._parent_ring cdef poly *p = self._poly if not x: if std_grading: - return self.total_degree(std_grading=True) - return singular_polynomial_deg(p, NULL, r) + return Integer(self.total_degree(std_grading=True)) + return Integer(singular_polynomial_deg(p, NULL, r)) if not x.parent() is self.parent(): try: @@ -2687,7 +2699,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): if not x.is_generator(): raise TypeError("argument is not a generator") - return singular_polynomial_deg(p, x._poly, r) + return Integer(singular_polynomial_deg(p, x._poly, r)) def total_degree(self, int std_grading=False): """ @@ -2739,6 +2751,14 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): -1 sage: R(1).total_degree() 0 + + Ensure that :issue:`37603` is fixed:: + sage: R. = QQ[] + sage: f = x^4 + y + z + sage: f.total_degree() + 4 + sage: type(f.total_degree()) + """ cdef int i, result cdef poly *p = self._poly @@ -2749,8 +2769,8 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): while p: result = max(result, sum([p_GetExp(p,i,r) for i in range(1,r.N+1)])) p = pNext(p) - return result - return singular_polynomial_deg(p, NULL, r) + return Integer(result) + return Integer(singular_polynomial_deg(p, NULL, r)) def degrees(self): """ @@ -2767,6 +2787,17 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): (1, 2, 1) sage: (q + y0^5).degrees() (5, 2, 1) + + TESTS: + + Ensure that :issue:`37603` is fixed:: + + sage: R. = QQ[] + sage: f = x^4 + y + z + sage: f.degrees() + (4, 1, 1) + sage: type(f.degrees()[0]) + """ cdef poly *p = self._poly cdef ring *r = self._parent_ring @@ -2776,7 +2807,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base): for i from 0 <= i < r.N: d[i] = max(d[i],p_GetExp(p, i+1, r)) p = pNext(p) - return tuple(d) + return tuple(map(Integer, d)) def coefficient(self, degrees): """