thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

random.shuffle fails if row in multidimensional array is None (Trac #2074) #5871

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2074 on 2012-03-05 by trac user tillahoffmann, assigned to unknown.

The random.shuffle fails if an array is multidimensional and one of the rows is None:

from numpy.random import shuffle
a = [1,2,3,None]
shuffle(a) #Works fine
b = [(1,1),(2,2),(3,3),None]
shuffle(b) #Fails

with the following error message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mtrand.pyx", line 4283, in mtrand.RandomState.shuffle (numpy/random/mtrand/mtrand.c:18131)
TypeError: 'NoneType' object is unsliceable