[Numpy-discussion] checksum on numpy float array
Robert Kern
robert.kern@gmail....
Thu Dec 4 19:11:20 CST 2008
On Thu, Dec 4, 2008 at 18:54, Brennan Williams
<brennan.williams@visualreservoir.com> wrote:
> Thanks
>
> josef.pktd@gmail.com wrote:
>> I didn't check what this does behind the scenes, but try this
>>
>>
> import hashlib #standard python library
> import numpy as np
>> m = hashlib.md5()
>> m.update(np.array(range(100)))
>> m.update(np.array(range(200)))
I would recommend doing this on the strings before you make arrays
from them. You don't know if the network cut out in the middle of an
8-byte double.
Of course, sending the lengths and other metadata first, then the data
would let you check without needing to do expensivish hashes or
checksums. If truncation is your problem rather than corruption, then
that would be sufficient. You may also consider using the NPY format
in numpy 1.2 to implement that.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion
mailing list