Skip to content

Instantly share code, notes, and snippets.

@graeme-winter
Created February 9, 2022 09:18
Show Gist options
  • Save graeme-winter/6afd4b8c513d5e48cc72b9db5294599a to your computer and use it in GitHub Desktop.
Save graeme-winter/6afd4b8c513d5e48cc72b9db5294599a to your computer and use it in GitHub Desktop.
Verify that the frames of an HDF5 file are all identical, and return the hash
import h5py
import hdf5plugin
import sys
def verify(filename):
with h5py.File(filename, "r") as f:
data = f["data"]
nn = data.shape[0]
h = None
for j in range(nn):
a = data[j, :, :]
a.flags.writeable = False
if h is None:
h = hash(a.data.tobytes())
else:
assert h == hash(a.data.tobytes())
print(filename, h)
for filename in sys.argv[1:]:
verify(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment