[Numpy-discussion] Adding a return value to np.random.shuffle

Joseph Fox-Rabinovitz jfoxrabinovitz at gmail.com
Thu Apr 12 14:00:58 EDT 2018


Sounds good. I will close the PR.

- Joe

On Thu, Apr 12, 2018 at 1:54 PM, Sebastian Berg <sebastian at sipsolutions.net>
wrote:

> On Thu, 2018-04-12 at 13:36 -0400, Joseph Fox-Rabinovitz wrote:
> > Would it break backwards compatibility to add the input as a return
> > value to np.random.shuffle? I doubt anyone out there is relying on
> > the None return value.
> >
>
> Well, python discourages this IIRC, and opts to not do these things for
> in place functions (see random package specifically). Numpy breaks this
> in a few places, but that is mostly because we have the out argument as
> an optional input argument.
>
> As is, it is a nice way of making people not write:
>
> new = np.random.shuffle(old)
>
> and think old won't change. So I think we should probably just stick
> with the python/Guido van Rossum ideals, or did those change?
>
> - Sebastian
>
>
>
> > The change is trivial, and allows shuffling a new array in one line
> > instead of two:
> >
> >     x = np.random.shuffle(np.array(some_junk))
> >
> > I've implemented the change in PR#10893.
> >
> > Regards,
> >
> > - Joe
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at python.org
> > https://mail.python.org/mailman/listinfo/numpy-discussion
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180412/458df1b6/attachment.html>


More information about the NumPy-Discussion mailing list