[Numpy-discussion] random permutation

Stefan van der Walt stefan at sun.ac.za
Sat Jan 13 16:15:55 EST 2007


On Sat, Jan 13, 2007 at 10:01:59AM -0800, Keith Goodman wrote:
> On 1/11/07, Robert Kern <robert.kern at gmail.com> wrote:
> > Keith Goodman wrote:
> > > Why is the first element of the permutation always the same? Am I
> > > using random.permutation in the right way?
> >
> > >>> M.__version__
> > > '1.0rc1'
> >
> > This has been fixed in more recent versions.
> >
> >   http://projects.scipy.org/scipy/numpy/ticket/374
> 
> I don't see any unit tests for numpy.random. I guess randomness is hard to test.

Every time we fix a bug, we add a corresponding test to make sure that it
doesn't pop up again.  In this case, take a look in
numpy/core/tests/test_regression.py:

def check_random_shuffle(self, level=rlevel):
    """Ticket #374"""
    a = N.arange(5).reshape((5,1))
    b = a.copy()
    N.random.shuffle(b)
    assert_equal(sorted(b),a)
    
Cheers
Stéfan



More information about the NumPy-Discussion mailing list