Skip to content

fix assert_equal for DataTree #10440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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)

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