Skip to content

Commit ed71fbb

Browse files
authored
Merge pull request #1256 from SixtyCapital/no-unbox-periods
PERF: Override equals in IndexVariable
2 parents d49014d + ff2545f commit ed71fbb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

xarray/core/variable.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,19 @@ def copy(self, deep=True):
12471247
return type(self)(self.dims, self._data, self._attrs,
12481248
self._encoding, fastpath=True)
12491249

1250+
def equals(self, other, equiv=None):
1251+
# if equiv is specified, super up
1252+
if equiv is not None:
1253+
return super(IndexVariable, self).equals(other, equiv)
1254+
1255+
# otherwise use the native index equals, rather than looking at _data
1256+
other = getattr(other, 'variable', other)
1257+
try:
1258+
return (self.dims == other.dims and
1259+
self._data_equals(other))
1260+
except (TypeError, AttributeError):
1261+
return False
1262+
12501263
def _data_equals(self, other):
12511264
return self.to_index().equals(other.to_index())
12521265

0 commit comments

Comments
 (0)