xarray
xarray copied to clipboard
fix assert_equal for DataTree
xr.testing.assert_equal(dt1, dt2) fails when the DataTree objects differ. Because diff_dataset_repr was called with "equal" instead of "equals" which does not call all(), leading to the following error
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
To reproduce:
import xarray as xr
ds1 = xr.Dataset(data_vars={"data": ("y", [5, 2])})
ds2 = xr.Dataset(data_vars={"data": (("x", "y"), [[5, 2]])})
dt1 = xr.DataTree.from_dict({"node": ds1})
dt2 = xr.DataTree.from_dict({"node": ds2})
xr.testing.assert_equal(dt1, dt2)