Skip to content

Commit

Permalink
impl. hdf5 example
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed May 23, 2023
1 parent 8f5ef2c commit 8d4f773
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions legate/examples/hdf5_io.py
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")

0 comments on commit 8d4f773

Please sign in to comment.