NeurodataWithoutBorders / lindi

Linked Data Interface (LINDI) - cloud-friendly access to NWB data
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Don't write .zattrs if there are no attributes #15

Closed rly closed 5 months ago

rly commented 5 months ago

This is minor. Zarr-python does not create a .zattrs file for a group or dataset without attributes. For consistency and to shrink the reference file system JSON, I suggest we do the same.

import zarr

store = zarr.NestedDirectoryStore("example-nds.zarr")
root = zarr.group(store, overwrite=True)
data_with_attr = root.create_dataset("data_with_attr", shape=(10,))
data_with_attr.attrs["a"] = 42
root.create_dataset("data_no_attr", shape=(10,))

for line in tree(Path("example-nds.zarr")):
    print(line)
├── .zgroup
├── data_with_attr
│   ├── .zarray
│   └── .zattrs
└── data_no_attr
    └── .zarray