From 476400bbc7e4e70088acc826dcf3fc336902201d Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 8 Feb 2017 14:02:28 -0500 Subject: [PATCH 1/2] override equals in IndexVariable --- xarray/core/variable.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index 156b0ac315d..c3f91657fbb 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -1247,6 +1247,19 @@ def copy(self, deep=True): return type(self)(self.dims, self._data, self._attrs, self._encoding, fastpath=True) + def equals(self, other, equiv=None): + # if equiv is specified, super up + if equiv: + return super(IndexVariable, self).equals(other, equiv) + + # otherwise use the native index equals, rather than looking at _data + other = getattr(other, 'variable', other) + try: + return (self.dims == other.dims and + self._data_equals(other)) + except (TypeError, AttributeError): + return False + def _data_equals(self, other): return self.to_index().equals(other.to_index()) From ff2545fe927ee39d9ce4d9a884b0ac045fa7a177 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 8 Feb 2017 22:16:11 -0500 Subject: [PATCH 2/2] is not none --- xarray/core/variable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index c3f91657fbb..9558327022e 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -1249,7 +1249,7 @@ def copy(self, deep=True): def equals(self, other, equiv=None): # if equiv is specified, super up - if equiv: + if equiv is not None: return super(IndexVariable, self).equals(other, equiv) # otherwise use the native index equals, rather than looking at _data