diff --git a/CHANGELOG.md b/CHANGELOG.md index 45fe964be..3667f0275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Write the date in place of the "Unreleased" in the case a new version is release ### Fixed - Propagate setting `include_data_sources` into child nodes. +- Populate attributes in member data variables and coordinates of xarray Datasets. ## v0.1.0a120 (25 April 2024) diff --git a/tiled/_tests/test_xarray.py b/tiled/_tests/test_xarray.py index 71221fde9..b6738824e 100644 --- a/tiled/_tests/test_xarray.py +++ b/tiled/_tests/test_xarray.py @@ -78,7 +78,7 @@ def client(): def test_xarray_dataset(client, key): expected = EXPECTED[key] actual = client[key].read().load() - xarray.testing.assert_equal(actual, expected) + xarray.testing.assert_identical(actual, expected) def test_specs(client): diff --git a/tiled/client/xarray.py b/tiled/client/xarray.py index a80f287aa..399c2a5ac 100644 --- a/tiled/client/xarray.py +++ b/tiled/client/xarray.py @@ -75,11 +75,13 @@ def _build_arrays(self, variables, optimize_wide_table): coords[name] = ( array_client.dims, coords_fetcher.register(name, array_client, array_structure), + array_client.metadata["attrs"], ) elif "xarray_data_var" in spec_names: data_vars[name] = ( array_client.dims, data_vars_fetcher.register(name, array_client, array_structure), + array_client.metadata["attrs"], ) else: raise ValueError( @@ -88,9 +90,17 @@ def _build_arrays(self, variables, optimize_wide_table): ) else: if "xarray_coord" in spec_names: - coords[name] = (array_client.dims, array_client.read()) + coords[name] = ( + array_client.dims, + array_client.read(), + array_client.metadata["attrs"], + ) elif "xarray_data_var" in spec_names: - data_vars[name] = (array_client.dims, array_client.read()) + data_vars[name] = ( + array_client.dims, + array_client.read(), + array_client.metadata["attrs"], + ) else: raise ValueError( "Child nodes of xarray_dataset should include spec "