Skip to content

Commit 5f11232

Browse files
committed
got old tests working
1 parent a4925b6 commit 5f11232

File tree

2 files changed

+5
-43
lines changed

2 files changed

+5
-43
lines changed

xarray/core/indexes.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,6 @@ def __getitem__(self, key):
3535
def __unicode__(self):
3636
return formatting.indexes_repr(self)
3737

38-
# class Indexes(Mapping, formatting.ReprMixin):
39-
# """Ordered Mapping[str, pandas.Index] for xarray objects.
40-
# """
41-
#
42-
# def __init__(self, variables, sizes):
43-
# """Not for public consumption.
44-
#
45-
# Parameters
46-
# ----------
47-
# variables : OrderedDict[Any, Variable]
48-
# Reference to OrderedDict holding variable objects. Should be the
49-
# same dictionary used by the source object.
50-
# sizes : OrderedDict[Any, int]
51-
# Map from dimension names to sizes.
52-
# """
53-
# self._variables = variables
54-
# self._sizes = sizes
55-
#
56-
# def _is_index_variable(self, key):
57-
# return (key in self._variables and key in self._sizes and
58-
# isinstance(self._variables[key], IndexVariable))
59-
#
60-
# def __iter__(self):
61-
# for key in self._sizes:
62-
# if self._is_index_variable(key):
63-
# yield key
64-
#
65-
# def __len__(self):
66-
# return sum(self._is_index_variable(key) for key in self._sizes)
67-
#
68-
# def __contains__(self, key):
69-
# self._is_index_variable(key)
70-
#
71-
# def __getitem__(self, key):
72-
# if not self._is_index_variable(key):
73-
# raise KeyError(key)
74-
# return self._variables[key].to_index()
75-
#
76-
# def __unicode__(self):
77-
# return formatting.indexes_repr(self)
78-
7938

8039
def default_indexes(coords, dims):
8140
"""Default indexes for a Dataset/DataArray.
@@ -93,4 +52,4 @@ def default_indexes(coords, dims):
9352
to indexes used for indexing along that dimension.
9453
"""
9554
return OrderedDict((key, coords[key].to_index())
96-
for key in dims if key in coords)
55+
for key in dims if key in coords and coords[key].ndim==1)

xarray/tests/test_dataset.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ def test_constructor(self):
237237

238238
with raises_regex(ValueError, 'conflicting sizes'):
239239
Dataset({'a': x1, 'b': x2})
240-
with raises_regex(TypeError, 'tuples of form'):
240+
# these are now allowed -- let's add a more explicit test
241+
#with raises_regex(ValueError, "disallows such variables"):
242+
# Dataset({'a': x1, 'x': z})
243+
with raises_regex(TypeError, 'tuple of form'):
241244
Dataset({'x': (1, 2, 3, 4, 5, 6, 7)})
242245
with raises_regex(ValueError, 'already exists as a scalar'):
243246
Dataset({'x': 0, 'y': ('x', [1, 2, 3])})

0 commit comments

Comments
 (0)