nDimensional sparse histogram in python.

Alex Martelli aleaxit at yahoo.com
Wed Feb 1 21:53:27 EST 2006


KraftDiner <bobrien18 at yahoo.com> wrote:
   ...
> histo = {[0,0,0]:1, [0,0,1]:2}
> Would indicate that there is one sample at 0,0,0 and two samples at
> 0,0,1
> but python tells me TypeError: list objects are unhashable
> 
> So any suggestions would be welcome.

Use tuples, not lists, as your keys:

histo = {(0,0,0):1, (0,0,1):2}


Alex



More information about the Python-list mailing list