[SciPy-dev] are arrays hashable?

Robert Kern rkern at ucsd.edu
Tue Sep 20 10:15:52 CDT 2005


Alan G Isaac wrote:
> A function that used to work fine with SciPy arrays 
> now chokes on the new scipy.base, claiming that 
> the new arrays are an unhashable type. 
> 
> For illustration only: 
> 
>>>>from scipy.base import * 
>>>>d = arange(11) 
>>>>set(d) 
> 
> Traceback (most recent call last): 
>   File "<stdin>", line 1, in ? 
> TypeError: unhashable type 

Arrays were never hashable, nor should they be since they are mutable.
The problem here is that set() isn't recognizing the array as an
iterable. With a slightly old CVS checkout, I get

In [10]: from scipy.base import *

In [11]: d = array(10)

In [12]: set(d)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most
recent call last)

/Users/kern/<console>

TypeError: iteration over non-sequence

In [13]: list(d)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most
recent call last)

/Users/kern/<console>

TypeError: iteration over non-sequence

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Scipy-dev mailing list