[Numpy-discussion] Request for enhancement to numpy.random.shuffle

Eelco Hoogendoorn hoogendoorn.eelco at gmail.com
Sun Oct 12 03:51:51 EDT 2014

Thanks Warren, I think these are sensible additions.

I would argue to treat the None-False condition as an error. Indeed I agree
one might argue the correcr behavior is to 'shuffle' the singleton block of
data, which does nothing; but its more likely to come up as an unintended
error than as a natural outcome of parametrized behavior.

On Sun, Oct 12, 2014 at 3:31 AM, John Zwinck <jzwinck at gmail.com> wrote:

> On Sun, Oct 12, 2014 at 6:51 AM, Warren Weckesser
> <warren.weckesser at gmail.com> wrote:
> > I created an issue on github for an enhancement
> > to numpy.random.shuffle:
> >     https://github.com/numpy/numpy/issues/5173
> I like this idea.  I was a bit surprised there wasn't something like
> this already.
> > A small wart in this API is the meaning of
> >
> >   shuffle(a, independent=False, axis=None)
> >
> > It could be argued that the correct behavior is to leave the
> > array unchanged. (The current behavior can be interpreted as
> > shuffling a 1-d sequence of monolithic blobs; the axis argument
> > specifies which axis of the array corresponds to the
> > sequence index.  Then `axis=None` means the argument is
> > a single monolithic blob, so there is nothing to shuffle.)
> > Or an error could be raised.
> Let's think about it from the other direction: if a user wants to
> shuffle all the elements as if it were 1-d, as you point out they
> could do this:
>   shuffle(a, axis=None, independent=True)
> But that's a lot of typing.  Maybe we should just let this do the same
> thing:
>   shuffle(a, axis=None)
> That seems to be in keeping with the other APIs taking axis as you
> mentioned.  To me, "independent" has no relevance when the array is
> 1-d, it can simply be ignored.
> John Zwinck
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141012/c55c0319/attachment.html>

More information about the NumPy-Discussion mailing list