Skip to content

Conversation

@mathause
Copy link
Collaborator

@mathause mathause commented Jun 23, 2025

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)

@mathause mathause merged commit 5f47a03 into pydata:main Jun 27, 2025
33 checks passed
@mathause mathause deleted the fix_assert_equal_for_dt branch June 27, 2025 09:48
@mathause mathause mentioned this pull request Jul 16, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant