From c79c0fb678fb6e7f27a966ce7fbadfae258aa3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Sat, 26 Jul 2014 02:09:37 +0200 Subject: [PATCH] fix unexpected behaviour of symbolic zero --- .../polynomial/multi_polynomial_element.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index b0aae126113..77b470a853a 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -1347,30 +1347,25 @@ def lt(self): def __eq__(self,right): """ + EXAMPLES:: + sage: x = PolynomialRing(RealField(42), 'x', 2).gens() + sage: x[0]^2 - x[1]^2 == SR(0) + x0^2 - x1^2 == 0 """ if not isinstance(right,MPolynomial_polydict): - # we want comparison with zero to be fast - if right == 0: - if self._MPolynomial_element__element.dict()=={}: - return True - else: - return False return self._richcmp_(right,2) return self._MPolynomial_element__element == right._MPolynomial_element__element def __ne__(self,right): """ + EXAMPLES:: + sage: x = PolynomialRing(RealField(42), 'x', 2).gens() + sage: x[0]^2 - x[1]^2 != SR(0) + x0^2 - x1^2 != 0 """ if not isinstance(right,MPolynomial_polydict): - # we want comparison with zero to be fast - if right == 0: - if self._MPolynomial_element__element.dict()=={}: - return False - else: - return True - # maybe add constant elements as well return self._richcmp_(right,3) return self._MPolynomial_element__element != right._MPolynomial_element__element