Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Bug fixes
of ``.T`` attributes. (:issue:`1675`).
By `Keisuke Fujii <https://github.com/fujiisoup>`_

Testing
~~~~~~~

- Add coordinate names to failure printout for
:py:func:`xarray.testing.assert_allclose`.
By `Matti Eskelinen <https://github.com/maaleske>`_

v0.10.0 rc1 (30 October 2017)
-----------------------------
Expand Down
5 changes: 3 additions & 2 deletions xarray/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ def assert_allclose(a, b, rtol=1e-05, atol=1e-08, decode_bytes=True):
# DataArray, so call into _data_allclose_or_equiv directly
allclose = _data_allclose_or_equiv(a.coords[v].values,
b.coords[v].values, **kwargs)
assert allclose, '{}\n{}'.format(a.coords[v].values,
b.coords[v].values)
assert allclose, 'coord {}:{}\n{}'.format(a.coords[v].name,
a.coords[v].values,
b.coords[v].values)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding name to the error message for non-coordinates, too? We could do this by adding an optional name argument to this function. (It would also be useful for assert_equal and assert_identical.)

elif isinstance(a, xr.Dataset):
assert set(a.data_vars) == set(b.data_vars)
assert set(a.coords) == set(b.coords)
Expand Down