From 2be53fad8853322bf59901dafa121273e56e0566 Mon Sep 17 00:00:00 2001 From: Marnix Date: Mon, 16 Dec 2024 08:44:11 +0100 Subject: [PATCH] Test that shows default unstructure behavior --- test/test_cattrs.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_cattrs.py b/test/test_cattrs.py index 68f6747..74fd620 100644 --- a/test/test_cattrs.py +++ b/test/test_cattrs.py @@ -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"]