Skip to content

Commit

Permalink
Differentiate order in equality (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitchoi authored May 12, 2020
1 parent 278c790 commit c3af7af
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
10 changes: 1 addition & 9 deletions traits/observers/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,13 @@ def __eq__(self, other):
""" Return true if the other value is an Expression with equivalent
content.
e.g. ``(trait("a") | trait("b")) == (trait("b") | trait("a"))`` will
return true.
Returns
-------
boolean
"""
if type(other) is not type(self):
return False
self_graphs = self._as_graphs()
other_graphs = other._as_graphs()
return (
len(self_graphs) == len(other_graphs)
and set(self_graphs) == set(other_graphs)
)
return self._as_graphs() == other._as_graphs()

def __or__(self, expression):
""" Create a new expression that matches this expression OR
Expand Down
9 changes: 0 additions & 9 deletions traits/observers/tests/test_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ def test_join_equality_with_then(self):

self.assertEqual(combined1, combined2)

def test_or_equality(self):
expr1 = create_expression(1)
expr2 = create_expression(2)

combined1 = expr1 | expr2
combined2 = expr2 | expr1
# order is ignored.
self.assertEqual(combined1, combined2)

def test_equality_different_type(self):
expr = create_expression(1)
self.assertNotEqual(expr, "1")
Expand Down

0 comments on commit c3af7af

Please sign in to comment.