Skip to content

Commit e5cb9ec

Browse files
author
Release Manager
committed
sagemathgh-39256: Add check for zero monomial in monomial_coefficient Fixes sagemath#39255 Added check for zero monomial and corresponding test case. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39256 Reported by: Vladimir Reviewer(s): Travis Scrimshaw
2 parents b84a0da + 9230780 commit e5cb9ec

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,15 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
29852985
-1
29862986
sage: f.monomial_coefficient(x^10)
29872987
0
2988+
2989+
TESTS::
2990+
2991+
sage: R.<x,y> = PolynomialRing(ZZ)
2992+
sage: f = x + y
2993+
sage: f.monomial_coefficient(x - x)
2994+
Traceback (most recent call last):
2995+
...
2996+
ValueError: mon must not be equal to 0
29882997
"""
29892998
cdef poly *p = self._poly
29902999
cdef poly *m = mon._poly
@@ -2993,6 +3002,9 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
29933002
if mon._parent is not self._parent:
29943003
raise TypeError("mon must have same parent as self.")
29953004

3005+
if mon._poly is NULL:
3006+
raise ValueError("mon must not be equal to 0")
3007+
29963008
while p:
29973009
if p_ExpVectorEqual(p, m, r) == 1:
29983010
return si2sa(p_GetCoeff(p, r), r, self._parent._base)

0 commit comments

Comments
 (0)