issues: 385716625
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
385716625 | MDU6SXNzdWUzODU3MTY2MjU= | 2582 | Keep attributes across operations | 8898319 | closed | 0 | 6 | 2018-11-29T12:36:32Z | 2018-12-12T17:11:22Z | 2018-12-12T17:11:22Z | CONTRIBUTOR | The ProblemWhen I have two DataArrays and I use a standard operation ( ```python import numpy as np import xarray as xr a = xr.DataArray(np.random.randn(3,3), dims=('x','y'), name='temp', attrs={'units':'K'}) b = xr.DataArray(np.random.randn(3,3), dims=('x','y'), name='temp', attrs={'units':'K'}) print(a) <xarray.DataArray 'temp' (x: 3, y: 3)> array([[ 1.207407, -1.9429 , 3.168454], [-0.773912, -0.121835, -0.139538], [ 1.823002, 0.185846, 0.53569 ]]) Dimensions without coordinates: x, y Attributes: units: K print(a-b) <xarray.DataArray 'temp' (x: 3, y: 3)> array([[ 1.280892, -1.097781, 2.150318], [-0.208202, -0.03856 , 0.805856], [ 2.192506, 1.049181, 2.277078]]) Dimensions without coordinates: x, y with xr.set_options(keep_attrs=True): print(a-b) <xarray.DataArray 'temp' (x: 3, y: 3)> array([[ 1.280892, -1.097781, 2.150318], [-0.208202, -0.03856 , 0.805856], [ 2.192506, 1.049181, 2.277078]]) Dimensions without coordinates: x, y ``` Problem descriptionAttributes vanish when a normal operation is applied!
From docs of set_options:
Expected OutputThe Attributes should remain. Maybe keep only attributes from the left Array ? Please adjust or advise me. Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2582/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |