From 53f80b347b345bd1b2d133162ebce8e6049c3dcd Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Fri, 11 Aug 2017 11:15:26 +0200 Subject: [PATCH 01/10] more detailed AssertionError message for assert_identical --- xarray/testing.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xarray/testing.py b/xarray/testing.py index c2bb5044ef4..e132d5c1156 100644 --- a/xarray/testing.py +++ b/xarray/testing.py @@ -1,6 +1,8 @@ """Testing functions exposed to the user API""" from __future__ import absolute_import, division, print_function +from io import StringIO + import numpy as np from xarray.core import duck_array_ops @@ -25,6 +27,12 @@ def _data_allclose_or_equiv(arr1, arr2, rtol=1e-05, atol=1e-08, arr1, arr2, rtol=rtol, atol=atol) +def _get_info_as_str(dataset): + buf = StringIO() + dataset.info(buf=buf) + return buf.getvalue() + + def assert_equal(a, b): """Like :py:func:`numpy.testing.assert_array_equal`, but for xarray objects. @@ -80,7 +88,10 @@ def assert_identical(a, b): assert a.name == b.name assert_identical(a._to_temp_dataset(), b._to_temp_dataset()) elif isinstance(a, (xr.Dataset, xr.Variable)): - assert a.identical(b), '{}\n{}'.format(a, b) + assert a.identical(b), ( + '{}\n{}\n---\n{}\n{}' + .format(a, b, _get_info_as_str(a), _get_info_as_str(b)) + ) else: raise TypeError('{} not supported by assertion comparison' .format(type(a))) From 9edfb9b6473e6916b07588d5d63a2210c23f8062 Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Tue, 15 Jan 2019 18:47:05 +0100 Subject: [PATCH 02/10] print differing dimensions/data/variables/attributes --- xarray/core/formatting.py | 142 ++++++++++++++++++++++++++++++++++++-- xarray/testing.py | 24 +++---- 2 files changed, 146 insertions(+), 20 deletions(-) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index 5dd3cf06025..8a90674ef32 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -13,6 +13,7 @@ import numpy as np import pandas as pd +from .duck_array_ops import array_equiv from .options import OPTIONS from .pycompat import ( PY2, bytes_type, dask_array_type, unicode_type, zip_longest) @@ -411,6 +412,15 @@ def short_dask_repr(array, show_dtype=True): return 'dask.array' % (array.shape, chunksize) +def short_data_repr(array): + if isinstance(getattr(array, 'variable', array)._data, dask_array_type): + return short_dask_repr(array) + elif array._in_memory or array.size < 1e5: + return short_array_repr(array.values) + else: + return u'[%s values with dtype=%s]' % (array.size, array.dtype) + + def array_repr(arr): # used for DataArray, Variable and IndexVariable if hasattr(arr, 'name') and arr.name is not None: @@ -421,12 +431,7 @@ def array_repr(arr): summary = [u'' % (type(arr).__name__, name_str, dim_summary(arr))] - if isinstance(getattr(arr, 'variable', arr)._data, dask_array_type): - summary.append(short_dask_repr(arr)) - elif arr._in_memory or arr.size < 1e5: - summary.append(short_array_repr(arr.values)) - else: - summary.append(u'[%s values with dtype=%s]' % (arr.size, arr.dtype)) + summary.append(short_data_repr(arr)) if hasattr(arr, 'coords'): if arr.coords: @@ -463,3 +468,128 @@ def dataset_repr(ds): summary.append(attrs_repr(ds.attrs)) return u'\n'.join(summary) + + +def diff_dim_summary(a, b): + if a.dims != b.dims: + ab_dim_summaries = [dim_summary(obj) for obj in (a, b)] + return "Differing dimensions:\n({}) != ({})".format(*ab_dim_summaries) + else: + return "" + + +def _diff_mapping_repr(a_mapping, b_mapping, compat, + title, summarizer, col_width=None): + + def extra_items_repr(extra_keys, vars, ab_side): + extra_repr = [summarizer(k, vars[k], col_width) for k in extra_keys] + if extra_repr: + return ["{} contains more {}:".format(ab_side, title)] + extra_repr + else: + return [] + + a_keys = set(a_mapping) + b_keys = set(b_mapping) + + summary = [] + + diff_items = [] + + for k in a_keys & b_keys: + try: + # compare xarray variable + compatible = getattr(a_mapping[k], compat)(b_mapping[k]) + is_variable = True + except AttributeError: + # compare attribute value + compatible = a_mapping[k] == b_mapping[k] + is_variable = False + + if not compatible: + temp = [summarizer(k, vars[k], col_width) + for vars in (a_mapping, b_mapping)] + + if compat == 'identical' and is_variable: + attrs_summary = [] + + for m in (a_mapping, b_mapping): + attr_s = "\n".join([summarize_attr(ak, av) + for ak, av in m[k].attrs.items()]) + attrs_summary.append(attr_s) + + temp = ["\n".join([var_s, attr_s]) if attr_s else var_s + for var_s, attr_s in zip(temp, attrs_summary)] + + diff_items += [ab_side + s[1:] + for ab_side, s in zip(('L', 'R'), temp)] + + if diff_items: + summary += ["Differing {}:".format(title)] + diff_items + + summary += extra_items_repr(a_keys - b_keys, a_mapping, "Left") + summary += extra_items_repr(b_keys - a_keys, b_mapping, "Right") + + return "\n".join(summary) + + +diff_coords_repr = functools.partial(_diff_mapping_repr, title="coordinates", + summarizer=summarize_coord) + + +diff_data_vars_repr = functools.partial(_diff_mapping_repr, + title="data variables", + summarizer=summarize_datavar) + + +diff_attrs_repr = functools.partial(_diff_mapping_repr, + title="attributes", + summarizer=summarize_attr) + + +def _compat_to_str(compat): + if compat == "equals": + return "equal" + else: + return compat + + +def diff_array_repr(a, b, compat): + # used for DataArray, Variable and IndexVariable + summary = ["Left and right {} objects are not {}" + .format(type(a).__name__, _compat_to_str(compat))] + + if not array_equiv(a.data, b.data): + temp = [wrap_indent(short_array_repr(obj), start=' ') + for obj in (a, b)] + diff_data_repr = [ab_side + "\n" + ab_data_repr + for ab_side, ab_data_repr in zip(('L', 'R'), temp)] + summary += ["Differing values:"] + diff_data_repr + + if hasattr(a, 'coords'): + col_width = _calculate_col_width(set(a.coords) | set(b.coords)) + summary.append(diff_coords_repr(a.coords, b.coords, compat, + col_width=col_width)) + + if compat == 'identical': + summary.append(diff_attrs_repr(a.attrs, b.attrs, compat)) + + return "\n".join(summary) + + +def diff_dataset_repr(a, b, compat): + summary = ["Left and right {} objects are not {}" + .format(type(a).__name__, _compat_to_str(compat))] + + col_width = _calculate_col_width( + set(_get_col_items(a.variables) + _get_col_items(b.variables))) + + summary.append(diff_dim_summary(a, b)) + summary.append(diff_coords_repr(a.coords, b.coords, compat, + col_width=col_width)) + summary.append(diff_data_vars_repr(a.data_vars, b.data_vars, compat, + col_width=col_width)) + + if compat == 'identical': + summary.append(diff_attrs_repr(a.attrs, b.attrs, compat)) + + return "\n".join(summary) diff --git a/xarray/testing.py b/xarray/testing.py index e132d5c1156..f89b04188d2 100644 --- a/xarray/testing.py +++ b/xarray/testing.py @@ -6,6 +6,7 @@ import numpy as np from xarray.core import duck_array_ops +from xarray.core import formatting def _decode_string_data(data): @@ -27,12 +28,6 @@ def _data_allclose_or_equiv(arr1, arr2, rtol=1e-05, atol=1e-08, arr1, arr2, rtol=rtol, atol=atol) -def _get_info_as_str(dataset): - buf = StringIO() - dataset.info(buf=buf) - return buf.getvalue() - - def assert_equal(a, b): """Like :py:func:`numpy.testing.assert_array_equal`, but for xarray objects. @@ -57,8 +52,10 @@ def assert_equal(a, b): import xarray as xr __tracebackhide__ = True # noqa: F841 assert type(a) == type(b) # noqa - if isinstance(a, (xr.Variable, xr.DataArray, xr.Dataset)): - assert a.equals(b), '{}\n{}'.format(a, b) + if isinstance(a, (xr.Variable, xr.DataArray)): + assert a.equals(b), formatting.diff_array_repr(a, b, 'equals') + elif isinstance(a, xr.Dataset): + assert a.equals(b), formatting.diff_dataset_repr(a, b, 'equals') else: raise TypeError('{} not supported by assertion comparison' .format(type(a))) @@ -84,14 +81,13 @@ def assert_identical(a, b): import xarray as xr __tracebackhide__ = True # noqa: F841 assert type(a) == type(b) # noqa - if isinstance(a, xr.DataArray): + if isinstance(a, xr.Variable): + assert a.identical(b), formatting.diff_array_repr(a, b, 'identical') + elif isinstance(a, xr.DataArray): assert a.name == b.name - assert_identical(a._to_temp_dataset(), b._to_temp_dataset()) + assert a.identical(b), formatting.diff_array_repr(a, b, 'identical') elif isinstance(a, (xr.Dataset, xr.Variable)): - assert a.identical(b), ( - '{}\n{}\n---\n{}\n{}' - .format(a, b, _get_info_as_str(a), _get_info_as_str(b)) - ) + assert a.identical(b), formatting.diff_dataset_repr(a, b, 'identical') else: raise TypeError('{} not supported by assertion comparison' .format(type(a))) From 07868e2f1b18afa8da157cb802f98d8858a9ad25 Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Tue, 15 Jan 2019 19:30:32 +0100 Subject: [PATCH 03/10] minor tweaks --- xarray/core/formatting.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index 8a90674ef32..03caa241661 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -472,8 +472,8 @@ def dataset_repr(ds): def diff_dim_summary(a, b): if a.dims != b.dims: - ab_dim_summaries = [dim_summary(obj) for obj in (a, b)] - return "Differing dimensions:\n({}) != ({})".format(*ab_dim_summaries) + return "Differing dimensions:\n ({}) != ({})".format( + dim_summary(a), dim_summary(b)) else: return "" @@ -481,8 +481,8 @@ def diff_dim_summary(a, b): def _diff_mapping_repr(a_mapping, b_mapping, compat, title, summarizer, col_width=None): - def extra_items_repr(extra_keys, vars, ab_side): - extra_repr = [summarizer(k, vars[k], col_width) for k in extra_keys] + def extra_items_repr(extra_keys, mapping, ab_side): + extra_repr = [summarizer(k, mapping[k], col_width) for k in extra_keys] if extra_repr: return ["{} contains more {}:".format(ab_side, title)] + extra_repr else: @@ -532,7 +532,8 @@ def extra_items_repr(extra_keys, vars, ab_side): return "\n".join(summary) -diff_coords_repr = functools.partial(_diff_mapping_repr, title="coordinates", +diff_coords_repr = functools.partial(_diff_mapping_repr, + title="coordinates", summarizer=summarize_coord) From 5f4f87ba7de30b461c5e895aa842be6c87cd4be0 Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Wed, 16 Jan 2019 11:11:02 +0100 Subject: [PATCH 04/10] add what's new entry --- doc/whats-new.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index b50df2af10e..4a351716fab 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -36,6 +36,11 @@ Enhancements - Upsampling an array via interpolation with resample is now dask-compatible, as long as the array is not chunked along the resampling dimension. By `Spencer Clark `_. +- :py:func:`xarray.testing.assert_equal` and + :py:func:`xarray.testing.assert_identical` now provide a more detailed + report showing what exactly differs between the two objects (dimensions / + coordinates / variables / attributes) (:issue:`1507`). + By `Benoit Bovy `_. Bug fixes ~~~~~~~~~ From 1469cde4589916789ce2cce24986b4227aeae1b7 Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Wed, 16 Jan 2019 12:06:10 +0100 Subject: [PATCH 05/10] add tests for diff_array_repr and diff_dataset_repr --- xarray/tests/test_formatting.py | 90 +++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 024c669bed9..46c6db0cd28 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -1,9 +1,12 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function +from textwrap import dedent + import numpy as np import pandas as pd +import xarray as xr from xarray.core import formatting from xarray.core.pycompat import PY3 @@ -190,6 +193,93 @@ def test_attribute_repr(self): assert u'\n' not in newlines assert u'\t' not in tabs + def test_diff_array_repr(self): + da_a = xr.DataArray([[1, 2, 3], [4, 5, 7]], + dims=('x', 'y'), + coords={'x': ['a', 'b'], 'y': [1, 2, 3]}, + attrs={'units': 'm', 'description': 'desc'}) + + da_b = xr.DataArray([1, 2], + dims='x', + coords={'x': ['a', 'c'], 'label': ('x', [1, 2])}, + attrs={'units': 'kg'}) + + expected = dedent("""\ + Left and right DataArray objects are not identical + Differing values: + L + array([[1, 2, 3], + [4, 5, 7]]) + R + array([1, 2]) + Differing coordinates: + L * x (x) Date: Wed, 16 Jan 2019 12:10:11 +0100 Subject: [PATCH 06/10] pep8 --- xarray/tests/test_formatting.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 46c6db0cd28..ddaf15d2c16 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -244,15 +244,19 @@ def test_diff_array_repr(self): assert actual == expected def test_diff_dataset_repr(self): - ds_a = xr.Dataset(data_vars={'var1': (('x', 'y'), [[1, 2, 3], [4, 5, 7]]), - 'var2': ('x', [3, 4])}, - coords={'x': ['a', 'b'], 'y': [1, 2, 3]}, - attrs={'units': 'm', 'description': 'desc'}) - - ds_b = xr.Dataset(data_vars={'var1': ('x', [1, 2])}, - coords={'x': ('x', ['a', 'c'], {'source': 0}), - 'label': ('x', [1, 2])}, - attrs={'units': 'kg'}) + ds_a = xr.Dataset( + data_vars={'var1': (('x', 'y'), [[1, 2, 3], [4, 5, 7]]), + 'var2': ('x', [3, 4])}, + coords={'x': ['a', 'b'], 'y': [1, 2, 3]}, + attrs={'units': 'm', 'description': 'desc'} + ) + + ds_b = xr.Dataset( + data_vars={'var1': ('x', [1, 2])}, + coords={'x': ('x', ['a', 'c'], {'source': 0}), + 'label': ('x', [1, 2])}, + attrs={'units': 'kg'} + ) expected = dedent("""\ Left and right Dataset objects are not identical From 6f0f704fc46e91ff45564a5c88b1b9137b939509 Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Wed, 16 Jan 2019 13:46:45 +0100 Subject: [PATCH 07/10] add differing dimensions in diff_array_repr --- xarray/core/formatting.py | 2 ++ xarray/tests/test_formatting.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index 03caa241661..20ae0710919 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -559,6 +559,8 @@ def diff_array_repr(a, b, compat): summary = ["Left and right {} objects are not {}" .format(type(a).__name__, _compat_to_str(compat))] + summary.append(diff_dim_summary(a, b)) + if not array_equiv(a.data, b.data): temp = [wrap_indent(short_array_repr(obj), start=' ') for obj in (a, b)] diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index ddaf15d2c16..94dc7b54f77 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -206,6 +206,8 @@ def test_diff_array_repr(self): expected = dedent("""\ Left and right DataArray objects are not identical + Differing dimensions: + (x: 2, y: 3) != (x: 2) Differing values: L array([[1, 2, 3], @@ -233,6 +235,8 @@ def test_diff_array_repr(self): expected = dedent("""\ Left and right Variable objects are not equal + Differing dimensions: + (x: 3) != (x: 2, y: 3) Differing values: L array([1, 2, 3]) From a4721ac9a37cf91c23840f43f53753512428049c Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Wed, 16 Jan 2019 13:47:17 +0100 Subject: [PATCH 08/10] fix tests (explicit numpy dtypes) --- xarray/tests/test_formatting.py | 50 ++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 94dc7b54f77..3626ce7927f 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -194,15 +194,19 @@ def test_attribute_repr(self): assert u'\t' not in tabs def test_diff_array_repr(self): - da_a = xr.DataArray([[1, 2, 3], [4, 5, 7]], - dims=('x', 'y'), - coords={'x': ['a', 'b'], 'y': [1, 2, 3]}, - attrs={'units': 'm', 'description': 'desc'}) - - da_b = xr.DataArray([1, 2], - dims='x', - coords={'x': ['a', 'c'], 'label': ('x', [1, 2])}, - attrs={'units': 'kg'}) + da_a = xr.DataArray( + np.array([[1, 2, 3], [4, 5, 6]], dtype='int64'), + dims=('x', 'y'), + coords={'x': np.array(['a', 'b'], dtype='U1'), + 'y': np.array([1, 2, 3], dtype='int64')}, + attrs={'units': 'm', 'description': 'desc'}) + + da_b = xr.DataArray( + np.array([1, 2], dtype='int64'), + dims='x', + coords={'x': np.array(['a', 'c'], dtype='U1'), + 'label': ('x', np.array([1, 2], dtype='int64'))}, + attrs={'units': 'kg'}) expected = dedent("""\ Left and right DataArray objects are not identical @@ -211,7 +215,7 @@ def test_diff_array_repr(self): Differing values: L array([[1, 2, 3], - [4, 5, 7]]) + [4, 5, 6]]) R array([1, 2]) Differing coordinates: @@ -230,8 +234,10 @@ def test_diff_array_repr(self): actual = formatting.diff_array_repr(da_a, da_b, 'identical') assert actual == expected - va = xr.Variable('x', [1, 2, 3], {'title': 'test Variable'}) - vb = xr.Variable(('x', 'y'), [[1, 2, 3], [4, 5, 6]]) + va = xr.Variable('x', np.array([1, 2, 3], dtype='int64'), + {'title': 'test Variable'}) + vb = xr.Variable(('x', 'y'), + np.array([[1, 2, 3], [4, 5, 6]], dtype='int64')) expected = dedent("""\ Left and right Variable objects are not equal @@ -249,16 +255,22 @@ def test_diff_array_repr(self): def test_diff_dataset_repr(self): ds_a = xr.Dataset( - data_vars={'var1': (('x', 'y'), [[1, 2, 3], [4, 5, 7]]), - 'var2': ('x', [3, 4])}, - coords={'x': ['a', 'b'], 'y': [1, 2, 3]}, + data_vars={ + 'var1': (('x', 'y'), + np.array([[1, 2, 3], [4, 5, 6]], dtype='int64')), + 'var2': ('x', np.array([3, 4], dtype='int64')) + }, + coords={'x': np.array(['a', 'b'], dtype='U1'), + 'y': np.array([1, 2, 3], dtype='int64')}, attrs={'units': 'm', 'description': 'desc'} ) ds_b = xr.Dataset( - data_vars={'var1': ('x', [1, 2])}, - coords={'x': ('x', ['a', 'c'], {'source': 0}), - 'label': ('x', [1, 2])}, + data_vars={'var1': ('x', np.array([1, 2], dtype='int64'))}, + coords={ + 'x': ('x', np.array(['a', 'c'], dtype='U1'), {'source': 0}), + 'label': ('x', np.array([1, 2], dtype='int64')) + }, attrs={'units': 'kg'} ) @@ -275,7 +287,7 @@ def test_diff_dataset_repr(self): Right contains more coordinates: label (x) int64 1 2 Differing data variables: - L var1 (x, y) int64 1 2 3 4 5 7 + L var1 (x, y) int64 1 2 3 4 5 6 R var1 (x) int64 1 2 Left contains more data variables: var2 (x) int64 3 4 From b6f4faa2d245af14a8a47d7f74807c5029d1d3bc Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Wed, 16 Jan 2019 14:15:28 +0100 Subject: [PATCH 09/10] fix tests (dtype shown / not shown in array repr) --- xarray/tests/test_formatting.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index 3626ce7927f..abf70cea6e1 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -215,9 +215,9 @@ def test_diff_array_repr(self): Differing values: L array([[1, 2, 3], - [4, 5, 6]]) + [4, 5, 6]], dtype=int64) R - array([1, 2]) + array([1, 2], dtype=int64) Differing coordinates: L * x (x) Date: Wed, 16 Jan 2019 14:26:48 +0100 Subject: [PATCH 10/10] minor tweaks --- xarray/core/formatting.py | 15 ++++++++------- xarray/testing.py | 2 -- xarray/tests/test_formatting.py | 14 +++++++------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index 20ae0710919..50fa64c9987 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -484,7 +484,8 @@ def _diff_mapping_repr(a_mapping, b_mapping, compat, def extra_items_repr(extra_keys, mapping, ab_side): extra_repr = [summarizer(k, mapping[k], col_width) for k in extra_keys] if extra_repr: - return ["{} contains more {}:".format(ab_side, title)] + extra_repr + header = "{} only on the {} object:".format(title, ab_side) + return [header] + extra_repr else: return [] @@ -524,26 +525,26 @@ def extra_items_repr(extra_keys, mapping, ab_side): for ab_side, s in zip(('L', 'R'), temp)] if diff_items: - summary += ["Differing {}:".format(title)] + diff_items + summary += ["Differing {}:".format(title.lower())] + diff_items - summary += extra_items_repr(a_keys - b_keys, a_mapping, "Left") - summary += extra_items_repr(b_keys - a_keys, b_mapping, "Right") + summary += extra_items_repr(a_keys - b_keys, a_mapping, "left") + summary += extra_items_repr(b_keys - a_keys, b_mapping, "right") return "\n".join(summary) diff_coords_repr = functools.partial(_diff_mapping_repr, - title="coordinates", + title="Coordinates", summarizer=summarize_coord) diff_data_vars_repr = functools.partial(_diff_mapping_repr, - title="data variables", + title="Data variables", summarizer=summarize_datavar) diff_attrs_repr = functools.partial(_diff_mapping_repr, - title="attributes", + title="Attributes", summarizer=summarize_attr) diff --git a/xarray/testing.py b/xarray/testing.py index f89b04188d2..418f1a08668 100644 --- a/xarray/testing.py +++ b/xarray/testing.py @@ -1,8 +1,6 @@ """Testing functions exposed to the user API""" from __future__ import absolute_import, division, print_function -from io import StringIO - import numpy as np from xarray.core import duck_array_ops diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index abf70cea6e1..6ca5e6f5363 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -221,14 +221,14 @@ def test_diff_array_repr(self): Differing coordinates: L * x (x)