Skip to content

Commit

Permalink
Propagate attributes for index variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed May 6, 2020
1 parent 4d40a25 commit 04ffa6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xarray/core/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ def map_blocks(
hlg.layers[gname_l] = layer

result = Dataset(coords=indexes, attrs=template.attrs)
for index in result.indexes:
result[index].attrs = template[index].attrs

for name, gname_l in var_key_map.items():
dims = template[name].dims
var_chunks = []
Expand Down
4 changes: 4 additions & 0 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ def make_da():
coords={"x": np.arange(10), "y": np.arange(100, 120)},
name="a",
).chunk({"x": 4, "y": 5})
da.x.attrs["long_name"] = "x"
da.attrs["test"] = "test"
da.coords["c2"] = 0.5
da.coords["ndcoord"] = da.x * 2
Expand All @@ -995,6 +996,9 @@ def make_ds():
map_ds.attrs["test"] = "test"
map_ds.coords["xx"] = map_ds["a"] * map_ds.y

map_ds.x.attrs["long_name"] = "x"
map_ds.y.attrs["long_name"] = "y"

return map_ds


Expand Down

0 comments on commit 04ffa6c

Please sign in to comment.