Created
February 4, 2016 17:10
-
-
Save ShigekiKarita/f9c98e5139c7fb63030f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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