[Numpy-discussion] shuffle bug

Tom Holroyd tomh at kurage.nimh.nih.gov
Fri Dec 8 05:47:41 CST 2006


This is certainly a bug. It has been mentioned before, but there 
was no comment.

shuffle() doesn't handle arrays.

>>> from numpy import *
>>> from numpy.random import *
>>> a = arange(12)
>>> a.shape = (6,2)
>>> a
array([[ 0,  1],
        [ 2,  3],
        [ 4,  5],
        [ 6,  7],
        [ 8,  9],
        [10, 11]])
>>> shuffle(a)
>>> a
array([[ 0,  1],
        [ 2,  3],
        [ 2,  3],
        [ 0,  1],
        [ 4,  5],
        [10, 11]])

This is with numpy 1.0. The [0, 1] element was duplicated. That's 
not right.

Tom Holroyd, Ph.D.
We experience the world not as it is, but as we expect it to be.


More information about the Numpy-discussion mailing list