issues: 1388326248
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1388326248 | I_kwDOAMm_X85SwC1o | 7093 | xarray allows several types for netcdf attributes. Is it expected ? | 10563614 | open | 0 | 3 | 2022-09-27T20:20:46Z | 2022-10-04T20:46:32Z | CONTRIBUTOR | What is your issue?Xarray is permissive regarding the type of the attributes. If using a wrong type, the error reveals the valid types: For serialization to netCDF files, its value must be of one of the following types: str, Number, ndarray, number, list, tuple Using a non iterable type used to raise an Exception when reading the saved netcdf, but this is now solved with #7085 The pending question is whether it is valid to save netcdf attributes with type other than a string or not. The following lines are working (in a notebook): ```python xr.DataArray([1, 2, 3], attrs={'units': 1}, name='x').to_netcdf("tmp.nc") !ncdump tmp.nc xr.DataArray([1, 2, 3], attrs={'units': np.nan}, name='x').to_netcdf("tmp.nc") !ncdump tmp.nc xr.DataArray([1, 2, 3], attrs={'units': ['xarray', 'is', 'very', 'permissive', ]}, name='x').to_netcdf("tmp.nc") !ncdump tmp.nc ``` On the other hand, the following line raises an error: ```python xr.DataArray([1, 2, 3], attrs={'units': None}, name='x').to_netcdf("tmp.nc") ``` |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7093/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |