home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 539022505

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3376#issuecomment-539022505 https://api.github.com/repos/pydata/xarray/issues/3376 539022505 MDEyOklzc3VlQ29tbWVudDUzOTAyMjUwNQ== 3642622 2019-10-07T13:53:48Z 2019-10-07T13:55:10Z NONE

Hello,

Yes, even with the option xr.set_options(keep_attrs=True), I still encounter the attributes changed. The full code with the set options is below.

#### Inputs ```python import xarray as xr import numpy as np xr.set_options(keep_attrs=True) import xarray as xr import numpy as np var1 = np.linspace(10, 15, 100) var2 = np.linspace(5, 10, 100) coords = np.linspace(1, 10, 100) dat = xr.Dataset( data_vars={'var1': ('coord', var1), 'var2': ('coord', var2)}, coords={'coord': coords} ) dat.attrs['model_id'] = 'model1' # coarsen dataset dat = dat.coarsen(coord=5, keep_attrs=True).mean() # print dataset dat ``` #### Actual Output ```python <xarray.Dataset> Dimensions: (coord: 20) Coordinates: * coord (coord) float64 1.182 1.636 2.091 2.545 ... 8.455 8.909 9.364 9.818 Data variables: var1 (coord) float64 10.1 10.35 10.61 10.86 ... 14.14 14.39 14.65 14.9 var2 (coord) float64 5.101 5.354 5.606 5.859 ... 9.141 9.394 9.646 9.899 ``` #### Expected Output ```python <xarray.Dataset> Dimensions: (coord: 20) Coordinates: * coord (coord) float64 1.182 1.636 2.091 2.545 ... 8.455 8.909 9.364 9.818 Data variables: var1 (coord) float64 10.1 10.35 10.61 10.86 ... 14.14 14.39 14.65 14.9 var2 (coord) float64 5.101 5.354 5.606 5.859 ... 9.141 9.394 9.646 9.899 Attributes: model_id: model1 ```

I'm not too familiar with the xarray package internals. But I will look to see if I can do my part and do a pull request. I'll get back to you after having a look at the internals.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  503425825
Powered by Datasette · Queries took 79.007ms · About: xarray-datasette