Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate order in Expression equality function #1080

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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