Skip to content

Commit 40c8d36

Browse files
committed
clean up formatting tests
1 parent 5f11232 commit 40c8d36

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

xarray/core/formatting.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,7 @@ def summarize_datavar(name, var, col_width):
272272

273273

274274
def summarize_coord(name, var, col_width):
275-
from .variable import IndexVariable
276-
# is there a cleaner way to check if something is an index variable?
277-
variable = getattr(var, 'variable', var)
278-
is_index = name in var.dims and isinstance(variable, IndexVariable)
275+
is_index = name in var.dims and var.ndim==1
279276
show_values = var._in_memory
280277
marker = u'*' if is_index else u' '
281278
if is_index:

xarray/tests/test_dataset.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def create_test_multiindex():
6060
return Dataset({}, {'x': mindex})
6161

6262

63+
def create_test_multidim_coord_no_index():
64+
ds = xr.Dataset({'a': ('x', [1, 1]),
65+
'x': (['x', 'y'], [[1, 1, 1, 1], [2, 2, 2, 2]])})
66+
return ds
67+
6368
class InaccessibleVariableDataStore(backends.InMemoryDataStore):
6469
def __init__(self):
6570
super(InaccessibleVariableDataStore, self).__init__()
@@ -176,6 +181,11 @@ def test_repr_period_index(self):
176181
# check that creating the repr doesn't raise an error #GH645
177182
repr(data)
178183

184+
def test_repr_no_index_on_multidim_coord(self):
185+
data = create_test_multidim_coord_no_index()
186+
actual = repr(data)
187+
assert '*' not in actual
188+
179189
def test_unicode_data(self):
180190
# regression test for GH834
181191
data = Dataset({u'foø': [u'ba®']}, attrs={u'å': u'∑'})
@@ -252,8 +262,7 @@ def test_constructor(self):
252262

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

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

265-
repr(ds)
266-
repr(ds.indexes)
267-
268274
def test_constructor_invalid_dims(self):
269275
# regression for GH1120
270276
with pytest.raises(MergeError):

0 commit comments

Comments
 (0)