On Fri, Oct 30, 2009 at 7:23 AM, Gael Varoquaux
<gael.varoqu...@normalesup.org> wrote:
> On Fri, Oct 30, 2009 at 08:21:16PM +0900, David Cournapeau wrote:
>> On Fri, Oct 30, 2009 at 8:04 PM, Sebastian Haase <seb.ha...@gmail.com> wrote:
>
>> > I understand where this error comes from, however what I was trying to
>> > do seems to "intuitive" that I would like to ask for suggestions:
>> > "What should I do if the "number" 2636 becomes unhashable ?"
>
>> In your example, that's the array which is unhashable, the numbers
>> itself should be hashable. Arrays are mutable, so I don't think you
>> can easily make them hashable. You could transform everything into
>> tuple of tuple of... if you need to use set, though.
>
> Use md5's of their .data attribute. This works quite well (you might want
> to hash a pickled string of the dtype in addition).
>
> Gaƫl

Careful... if your data is not contiguous in memory then you could be
adding lots of random noise to your hash key by doing this.  This
could cause equal ndarrays to hash to different values -- not good.
Make sure memory is contiguous before hashing the .data.  Flatten()
does this i think, as does copy(), array(), and many others.

James
-- 
http://www-etud.iro.umontreal.ca/~bergstrj
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to