Skip to content

Commit

Permalink
Test that shows default unstructure behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
deltamarnix committed Dec 16, 2024
1 parent f14ed45 commit 2be53fa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_cattrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,16 @@ def test_unstructure_xarray_tree():
# the xarray as is.
# This helps when finally converting the dictionary to MF6 input files.
assert x_tree is f_dict["x"]


def test_unstructure_xarray_tree_no_hook():
x_arr = xr.DataArray([1, 2, 3])
x_set = xr.Dataset({"x": x_arr})
x_tree = xr.DataTree(x_set)
f = Baz(x=x_tree)

f_dict = unstructure(f)

# Unfortunately the default converter seems to make a copy of the DataTree
# and doesn't keep the original reference.
assert x_tree is not f_dict["x"]

0 comments on commit 2be53fa

Please sign in to comment.