[Numpy-discussion] Should array iterate over a set?

Michael McNeil Forbes mforbes at physics.ubc.ca
Sat Nov 17 21:19:04 EST 2007


My expectation was that array would iterate over a set.  This is  
incorrect:

 >>> array(set([1,2,3]))
array(set([1, 2, 3]), dtype=object)

Is this the intended behaviour?  A trivial work-around that does what  
I need is

 >>> array(list(set([1,2,3])))
array([1, 2, 3])

but I was wondering if this was by design or just a forgotten  
corner.  (Maybe a vestige of the tuple special case for record arrays?)

Michael.

P.S. I just found that this was brought up by Ed Schofield on  
2006-05-03, but there were no replies in that thread.




More information about the NumPy-Discussion mailing list