Skip to content

Commit 04ffa6c

Browse files
committed
Propagate attributes for index variables.
1 parent 4d40a25 commit 04ffa6c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

xarray/core/parallel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ def map_blocks(
541541
hlg.layers[gname_l] = layer
542542

543543
result = Dataset(coords=indexes, attrs=template.attrs)
544+
for index in result.indexes:
545+
result[index].attrs = template[index].attrs
546+
544547
for name, gname_l in var_key_map.items():
545548
dims = template[name].dims
546549
var_chunks = []

xarray/tests/test_dask.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ def make_da():
972972
coords={"x": np.arange(10), "y": np.arange(100, 120)},
973973
name="a",
974974
).chunk({"x": 4, "y": 5})
975+
da.x.attrs["long_name"] = "x"
975976
da.attrs["test"] = "test"
976977
da.coords["c2"] = 0.5
977978
da.coords["ndcoord"] = da.x * 2
@@ -995,6 +996,9 @@ def make_ds():
995996
map_ds.attrs["test"] = "test"
996997
map_ds.coords["xx"] = map_ds["a"] * map_ds.y
997998

999+
map_ds.x.attrs["long_name"] = "x"
1000+
map_ds.y.attrs["long_name"] = "y"
1001+
9981002
return map_ds
9991003

10001004

0 commit comments

Comments
 (0)