[Chicago] sha1 of equal arrays different?

Kyle Cronan kyle at pbx.org
Tue Oct 9 05:44:10 CEST 2012

I don't think I'm seeing that with my numpy here but maybe try passing
the view to buffer() before hashing?


On Mon, Oct 8, 2012 at 10:07 PM, Oren Livne <livne at uchicago.edu> wrote:
> Dear All,
> I have a boolean numpy matrix whose rows 1 and 2 are equal. When I hash them
> using astype(uint8), I get equal digests, but different digests if
> view(uint8) is used. Why is that, or how can I interrogate the internals of
> the arrays to see why this happens? I rather use view(), because it's faster
> and requires no additional allocation. In IPython on top of Python 2.7.3.
> h[1]
> [ True False False False  True  True False  True  True True]
> h[2]
> [ True False False False  True  True False  True  True True]
> sha1(h[1].astype(uint8)).hexdigest(), sha1(h[2].astype(uint8)).hexdigest()
> ('bc4ec9b78ad53ce78ae24643d8ff302a9ae03bd0',
> 'bc4ec9b78ad53ce78ae24643d8ff302a9ae03bd0')
> sha1(h[1].view(uint8)).hexdigest(), sha1(h[2].view(uint8)).hexdigest()
> ('887ed6519d5b521fe5181f9329b98c65897a6a47',
> 'd8cb41ec47d6e01c25986bbd605d39e777e5b4f7')
> Thank you so much,
> Oren
> --
> A person is just about as big as the things that make him angry.
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago

More information about the Chicago mailing list