Skip to content

Instantly share code, notes, and snippets.

@ShigekiKarita
Created February 4, 2016 17:10
Show Gist options
  • Save ShigekiKarita/f9c98e5139c7fb63030f to your computer and use it in GitHub Desktop.
Save ShigekiKarita/f9c98e5139c7fb63030f to your computer and use it in GitHub Desktop.
import h5py
import numpy
dataset_path = "./dataset.hdf5"
def save_h5py(name, data):
f = h5py.File(dataset_path)
f.create_dataset(name, data=data, compression="gzip")
f.close()
def load_h5py(name):
f = h5py.File(dataset_path, "r")
return f[name]
def test_h5py():
a = numpy.random.randn(3,4)
name = "hoge"
save_h5py(name, a)
b = load_h5py(name)
assert (a == b).all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment