Skip to content

Commit b3d67fd

Browse files
committed
first fixes
1 parent 8496359 commit b3d67fd

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

mathics/builtin/comparison.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from mathics.version import __version__ # noqa used in loading to check consistency.
55

6-
import itertools
76
from typing import Optional, Union
87

98
import sympy
@@ -218,6 +217,7 @@ class _EqualityOperator(_InequalityOperator):
218217
"Compares all pairs e.g. a == b == c compares a == b, b == c, and a == c."
219218

220219
def do_compare(self, l1, l2) -> Union[bool, None]:
220+
print("do_compare:", (l1,l2))
221221
if l1.same(l2):
222222
return True
223223
elif l1 == SymbolTrue and l2 == SymbolFalse:
@@ -279,7 +279,9 @@ def apply(self, items, evaluation):
279279
return self.apply_other(items, evaluation)
280280
args = self.numerify_args(items, evaluation)
281281
wanted = operators[self.get_name()]
282-
for x, y in itertools.combinations(args, 2):
282+
pairs = zip(args[:-1],args[1:])
283+
print("apply:", args)
284+
for x, y in pairs:
283285
if isinstance(x, String) or isinstance(y, String):
284286
if not (isinstance(x, String) and isinstance(y, String)):
285287
c = 1
@@ -297,7 +299,9 @@ def apply(self, items, evaluation):
297299
def apply_other(self, args, evaluation):
298300
"%(name)s[args___?(!ExactNumberQ[#]&)]"
299301
args = args.get_sequence()
300-
for x, y in itertools.combinations(args, 2):
302+
pairs = zip(args[:-1],args[1:])
303+
print("apply_other:", args)
304+
for x, y in pairs:
301305
c = self.do_compare(x, y)
302306
if c is None:
303307
return

test/test_compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def test_compare():
2929
for str_expr, str_expected in (
3030
# Tests that do not passes
31-
#("Infinity==I", "False"),
31+
("Infinity==I", "False"),
3232
# ("Infinity==3+2 I", "False"),
3333
# (
3434
# '2 + 3*a==StringStream["Tengo una vaca lechera"]',

0 commit comments

Comments
 (0)