home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 822300379

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/4311#issuecomment-822300379 https://api.github.com/repos/pydata/xarray/issues/4311 822300379 MDEyOklzc3VlQ29tbWVudDgyMjMwMDM3OQ== 49512274 2021-04-19T08:59:27Z 2021-04-19T08:59:27Z NONE

Problem found.

Another example with more minimalistic code :

```python zname = '/tmp/test.zarr' zh = zarr.open(zname, "w")

data = np.ones(10, dtype=np.uint32) za = zh.array("example", data) za.attrs["_ARRAY_DIMENSIONS"] = ["obs"] # or won't be read by xarray

print("zarr : ", za.dtype, za[:])

ds = xr.open_zarr(zname) print("xarray : ", ds.example.dtype, ds.example.values) python

zarr : uint32 [1 1 1 1 1 1 1 1 1 1] xarray : float64 [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] ```

After investigations, i found that you have to explicitly pass fill_value=None :

```python zname = '/tmp/test.zarr' zh = zarr.open(zname, "w")

data = np.ones(10, dtype=np.uint32) za = zh.array("example", data, fill_value=None) # <-- default fill_value=0

za.attrs["_ARRAY_DIMENSIONS"] = ["obs"] print("zarr : ", za.dtype, za[:])

ds = xr.open_zarr(zname) print("xarray : ", ds.example.dtype, ds.example.values) python

zarr : uint32 [1 1 1 1 1 1 1 1 1 1] xarray : uint32 [1 1 1 1 1 1 1 1 1 1] ```

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