Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix unexpected behaviour of symbolic zero
Browse files Browse the repository at this point in the history
  • Loading branch information
a-andre committed Jul 26, 2014
1 parent 169b80c commit c79c0fb
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/sage/rings/polynomial/multi_polynomial_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c79c0fb

Please sign in to comment.