[Chicago] sha1 of equal arrays different?

Oren Livne livne at uchicago.edu
Tue Oct 9 17:55:52 CEST 2012


Yes, this works for me too (2.7.3 / numpy 1.6.2). But try the test case 
I sent after that - I think it's the initial slicing of the matrix that 
leads to different sha1(view()) values. At any rate, hashing with 
tostring() instead works. Thanks !!

On 10/09/2012 12:19 AM, Sunah Suh wrote:
> Welp, I just tried to reproduce your behavior in the repl and.. got 
> sha1 digests that were identical to the ones that you get when you use 
> astype:
> >>> row1
> array([ True, False, False, False,  True,  True, False,  True,  True, 
>  True], dtype=bool)
> >>> row2
> array([ True, False, False, False,  True,  True, False,  True,  True, 
>  True], dtype=bool)
> >>> hashlib.sha1(row1.view(numpy.uint8)).hexdigest(), 
> hashlib.sha1(row2.view(numpy.uint8)).hexdigest()
> ('bc4ec9b78ad53ce78ae24643d8ff302a9ae03bd0', 
> 'bc4ec9b78ad53ce78ae24643d8ff302a9ae03bd0')
>
> Maddening, isn't it? If it helps, that was with the 2.7.2 version that 
> ships with os x mountain lion and numpy 1.6.1
>
> -S
>
>
> On Mon, Oct 8, 2012 at 10:44 PM, Kyle Cronan <kyle at pbx.org 
> <mailto:kyle at pbx.org>> wrote:
>
>     I don't think I'm seeing that with my numpy here but maybe try passing
>     the view to buffer() before hashing?
>
>     -Kyle
>
>     On Mon, Oct 8, 2012 at 10:07 PM, Oren Livne <livne at uchicago.edu
>     <mailto: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 <mailto:Chicago at python.org>
>     > http://mail.python.org/mailman/listinfo/chicago
>     _______________________________________________
>     Chicago mailing list
>     Chicago at python.org <mailto:Chicago at python.org>
>     http://mail.python.org/mailman/listinfo/chicago
>
>
>
>
> -- 
> Sunah Suh
> Software Engineer @ Etsy
> Full-Stack Web Developer, Pythonista, Jill-of-all-trades
> Intermittent Winner in Life
> Website: sunahsuh.com <http://sunahsuh.com> | GChat: 
> sunah at sunahsuh.com <mailto:sunah at sunahsuh.com>
> Check my current email load: http://courteous.ly/d7mWb4
>
>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20121009/943707a8/attachment.html>


More information about the Chicago mailing list