-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. | ||
# See file LICENSE for terms. | ||
|
||
|
||
import h5py | ||
import numpy as np | ||
|
||
import legate_kvikio.kerchunk | ||
import legate_kvikio.zarr | ||
|
||
|
||
def hdf5_io(filename): | ||
a = np.arange(10000).reshape((100, 100)) | ||
|
||
# Write array using h5py | ||
with h5py.File(filename, "w") as f: | ||
f.create_dataset("mydataset", chunks=(10, 10), data=a) | ||
|
||
# Read hdf5 file using legate+kerchunk | ||
b = legate_kvikio.kerchunk.hdf5_read(filename, dataset_name="mydataset") | ||
|
||
# They should be equal | ||
assert (a == b).all() | ||
|
||
|
||
if __name__ == "__main__": | ||
hdf5_io("/tmp/legate-kvikio-io.hdf5") |