home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 522187284

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
522187284 MDU6SXNzdWU1MjIxODcyODQ= 3517 Support for nested dictionaries in atttributes for Zarr 3780274 open 0     2 2019-11-13T12:28:58Z 2019-11-13T22:53:43Z   NONE      

Similar to #2868, but for Zarr. In this case Zarr should support saving nested dictionaries.

import xarray as xr ds = xr.Dataset() ds.attrs['foo'] = {'bar': 1} ds.to_zarr('foo.zarr', mode='w')

Error message:

``` TypeError Traceback (most recent call last) <ipython-input-11-4e7ad4f0a599> in <module> ----> 1 ds.to_zarr('ll.zarr', mode='w')

/srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/core/dataset.py in to_zarr(self, store, mode, synchronizer, group, encoding, compute, consolidated, append_dim) 1614 compute=compute, 1615 consolidated=consolidated, -> 1616 append_dim=append_dim, 1617 ) 1618

/srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/backends/api.py in to_zarr(dataset, store, mode, synchronizer, group, encoding, compute, consolidated, append_dim) 1299 # validate Dataset keys, DataArray names, and attr keys/values 1300 _validate_dataset_names(dataset) -> 1301 _validate_attrs(dataset) 1302 1303 if mode == "a":

/srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/backends/api.py in _validate_attrs(dataset) 209 # Check attrs on the dataset itself 210 for k, v in dataset.attrs.items(): --> 211 check_attr(k, v) 212 213 # Check attrs on each variable within the dataset

/srv/conda/envs/notebook/lib/python3.7/site-packages/xarray/backends/api.py in check_attr(name, value) 204 "a string, an ndarray or a list/tuple of " 205 "numbers/strings for serialization to netCDF " --> 206 "files".format(value) 207 ) 208

TypeError: Invalid value for attr: {'bar': 1} must be a number, a string, an ndarray or a list/tuple of numbers/strings for serialization to netCDF files ```

Additionally the error message mentions netCDF -- even if I am writing a Zarr file.

Workaround is to save as a list, i.e.

ds.attrs['foo'] = [{'bar': 1}]

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3517/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 1.737ms · About: xarray-datasette