Skip to content

Commit

Permalink
Raise NotImplementedError when attempting to use a pandas.MultiIndex
Browse files Browse the repository at this point in the history
Related: pydata#164
  • Loading branch information
shoyer committed Jul 31, 2014
1 parent 20d1939 commit f2057b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/test_data_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def test_constructor_from_self_described(self):
actual = DataArray(Coordinate('foo', ['a', 'b']))
self.assertDataArrayIdentical(expected, actual)

s = pd.Series(range(2), pd.MultiIndex.from_product([['a', 'b'], [0]]))
with self.assertRaisesRegexp(NotImplementedError, 'MultiIndex'):
DataArray(s)

def test_equals_and_identical(self):
da2 = self.dv.copy()
self.assertTrue(self.dv.equals(da2))
Expand Down
5 changes: 5 additions & 0 deletions xray/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ class Coordinate(Variable):
_cache_data_class = PandasIndexAdapter

def __init__(self, name, data, attributes=None, encoding=None):
if isinstance(data, pd.MultiIndex):
raise NotImplementedError(
'no support yet for using a pandas.MultiIndex in an '
'xray.Coordinate')

super(Coordinate, self).__init__(name, data, attributes, encoding)
if self.ndim != 1:
raise ValueError('%s objects must be 1-dimensional' %
Expand Down

0 comments on commit f2057b1

Please sign in to comment.