From 2b47d9ac6b84d6a5d78bfa46d046694036471666 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Wed, 13 Oct 2021 14:33:47 -0500 Subject: [PATCH] Array.__eq__ should call pt.equality.is_structurally_equivalent --- pytato/array.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pytato/array.py b/pytato/array.py index e5b1d8363..be04a3c55 100644 --- a/pytato/array.py +++ b/pytato/array.py @@ -464,11 +464,9 @@ def __hash__(self) -> int: def __eq__(self, other: Any) -> bool: if self is other: return True - return ( - isinstance(other, type(self)) - and all( - getattr(self, field) == getattr(other, field) - for field in self._fields)) + + from pytato.equality import is_structurally_equivalent + return is_structurally_equivalent(self, other) def __ne__(self, other: Any) -> bool: return not self.__eq__(other) @@ -788,8 +786,8 @@ def __eq__(self, other: Any) -> bool: if self is other: return True - return (isinstance(other, DictOfNamedArrays) - and self._data == other._data) + from pytato.equality import is_structurally_equivalent + return is_structurally_equivalent(self, other) # }}}