str(random_matrix)
will not include all of the matrix due to numpy's eliding things with "...":
>>> x = np.ones((1000, 1000))
>>> print str(x)
[[ 1. 1. 1. ..., 1. 1. 1.]
[ 1. 1. 1. ..., 1. 1. 1.]
[ 1. 1. 1. ..., 1. 1. 1.]
...,
[ 1. 1. 1. ..., 1. 1. 1.]
[ 1. 1. 1. ..., 1. 1. 1.]
[ 1. 1. 1. ..., 1. 1. 1.]]
So when you hash str(random_matrix)
, you aren't really hashing all the data.
See this previous question and this one about how to hash numpy arrays.