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

Commit c79c0fb

Browse files
committed
fix unexpected behaviour of symbolic zero
1 parent 169b80c commit c79c0fb

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/sage/rings/polynomial/multi_polynomial_element.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,30 +1347,25 @@ def lt(self):
13471347

13481348
def __eq__(self,right):
13491349
"""
1350+
EXAMPLES::
13501351
1352+
sage: x = PolynomialRing(RealField(42), 'x', 2).gens()
1353+
sage: x[0]^2 - x[1]^2 == SR(0)
1354+
x0^2 - x1^2 == 0
13511355
"""
13521356
if not isinstance(right,MPolynomial_polydict):
1353-
# we want comparison with zero to be fast
1354-
if right == 0:
1355-
if self._MPolynomial_element__element.dict()=={}:
1356-
return True
1357-
else:
1358-
return False
13591357
return self._richcmp_(right,2)
13601358
return self._MPolynomial_element__element == right._MPolynomial_element__element
13611359

13621360
def __ne__(self,right):
13631361
"""
1362+
EXAMPLES::
13641363
1364+
sage: x = PolynomialRing(RealField(42), 'x', 2).gens()
1365+
sage: x[0]^2 - x[1]^2 != SR(0)
1366+
x0^2 - x1^2 != 0
13651367
"""
13661368
if not isinstance(right,MPolynomial_polydict):
1367-
# we want comparison with zero to be fast
1368-
if right == 0:
1369-
if self._MPolynomial_element__element.dict()=={}:
1370-
return False
1371-
else:
1372-
return True
1373-
# maybe add constant elements as well
13741369
return self._richcmp_(right,3)
13751370
return self._MPolynomial_element__element != right._MPolynomial_element__element
13761371

0 commit comments

Comments
 (0)