[Chicago] sha1 of equal arrays different?

Oren Livne livne at uchicago.edu
Tue Oct 9 05:07:15 CEST 2012


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.



More information about the Chicago mailing list