def test_compression(tmp_path, compression_dict): root = tmp_path / "test.n5" data = np.arange(100, dtype=np.uint8).reshape((10, 10)) pyn5.create_dataset(str(root), "ds", data.shape, (5, 5), data.dtype.name.upper(), json.dumps(compression_dict)) with open(root / "ds" / "attributes.json") as f: attrs = json.load(f) assert attrs["compression"] == compression_dict ds = pyn5.DatasetUINT8(str(root), "ds", True) ds.write_ndarray((0, 0), data, 0)
def test_data_ordering(tmp_path): root = tmp_path / "test.n5" shape = (10, 20) chunks = (10, 10) pyn5.create_dataset(str(root), "ds", shape, chunks, "UINT8") ds = pyn5.DatasetUINT8(str(root), "ds", False) arr = np.array(ds.read_ndarray((0, 0), shape)) arr += 1 ds.write_ndarray((0, 0), arr, 0) ds_path = root / "ds" assert blocks_in(ds_path) == {"0", "0/0", "0/1"} with open(ds_path / "attributes.json") as f: attrs = json.load(f) assert list(shape) == attrs["dimensions"]