Skip to content

Commit

Permalink
clean up formatting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rabernat committed Jan 19, 2019
1 parent 5f11232 commit 40c8d36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 1 addition & 4 deletions xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ def summarize_datavar(name, var, col_width):


def summarize_coord(name, var, col_width):
from .variable import IndexVariable
# is there a cleaner way to check if something is an index variable?
variable = getattr(var, 'variable', var)
is_index = name in var.dims and isinstance(variable, IndexVariable)
is_index = name in var.dims and var.ndim==1
show_values = var._in_memory
marker = u'*' if is_index else u' '
if is_index:
Expand Down
16 changes: 11 additions & 5 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def create_test_multiindex():
return Dataset({}, {'x': mindex})


def create_test_multidim_coord_no_index():
ds = xr.Dataset({'a': ('x', [1, 1]),
'x': (['x', 'y'], [[1, 1, 1, 1], [2, 2, 2, 2]])})
return ds

class InaccessibleVariableDataStore(backends.InMemoryDataStore):
def __init__(self):
super(InaccessibleVariableDataStore, self).__init__()
Expand Down Expand Up @@ -176,6 +181,11 @@ def test_repr_period_index(self):
# check that creating the repr doesn't raise an error #GH645
repr(data)

def test_repr_no_index_on_multidim_coord(self):
data = create_test_multidim_coord_no_index()
actual = repr(data)
assert '*' not in actual

def test_unicode_data(self):
# regression test for GH834
data = Dataset({u'foø': [u'ba®']}, attrs={u'å': u'∑'})
Expand Down Expand Up @@ -252,8 +262,7 @@ def test_constructor(self):

def test_constructor_multidim_dimensions(self):
# checks related to GH2368, GH2233
ds = xr.Dataset({'a': ('x', 2 * np.arange(100)),
'x': (['x', 'y'], np.arange(1000).reshape(100, 10))})
ds = create_test_multidim_coord_no_index()

# dataset should have no indices
assert not isinstance(ds.variables['x'], IndexVariable)
Expand All @@ -262,9 +271,6 @@ def test_constructor_multidim_dimensions(self):
with pytest.raises(KeyError):
ds.indexes['x']

repr(ds)
repr(ds.indexes)

def test_constructor_invalid_dims(self):
# regression for GH1120
with pytest.raises(MergeError):
Expand Down

0 comments on commit 40c8d36

Please sign in to comment.