Skip to content

Instantly share code, notes, and snippets.

@Jim-Holmstroem
Created February 21, 2012 10:51
Show Gist options
  • Save Jim-Holmstroem/1875766 to your computer and use it in GitHub Desktop.
Save Jim-Holmstroem/1875766 to your computer and use it in GitHub Desktop.
Hash numpy.array
from hashlib import sha1
import numpy
arr=numpy.zeros((256,256,4))
sha1(arr)
@alex-petrenko
Copy link

Also, make sure your array is C-contigious, otherwise hashing will not work.
Simple fix:

    if not x.flags['C_CONTIGUOUS']:
        x = np.ascontiguousarray(x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment