New random.Generator method: permuted

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

New random.Generator method: permuted

Warren Weckesser-2
In one of the previous weekly zoom meetings, it was suggested
to ping the mailing list about an updated PR that implements
the `permuted` method for the Generator class in numpy.random.
The relevant issue is

    https://github.com/numpy/numpy/issues/5173

and the PR is

    https://github.com/numpy/numpy/pull/15121

The new method (as it would be called from Python) is

    permuted(x, axis=None, out=None)

The CircleCI rendering of the docstring from the pull request is

    https://14745-908607-gh.circle-artifacts.com/0/doc/build/html/reference/random/generated/numpy.random.Generator.permuted.html

The new method is an alternative to the existing `shuffle` and
`permutation` methods.  It handles the `axis` parameter similar
to how the sort methods do, i.e. when `axis` is given, the slices
along the axis are shuffled independently.  This new documentation
(added as part of the pull request) explains the API of the various
related methods:

    https://14745-908607-gh.circle-artifacts.com/0/doc/build/html/reference/random/generator.html#permutations

Additional feedback on the implementation of `permuted` in the
pull request is welcome.  Further discussion of the API should
be held in the issue gh-5173 (but please familiarize yourself
with the discussion of the API in gh-5173--there has already
been quite a long discussion of several different APIs).

Thanks,

Warren
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: New random.Generator method: permuted

Sebastian Berg
On Mon, 2020-08-03 at 14:09 -0400, Warren Weckesser wrote:

> In one of the previous weekly zoom meetings, it was suggested
> to ping the mailing list about an updated PR that implements
> the `permuted` method for the Generator class in numpy.random.
> The relevant issue is
>
>     https://github.com/numpy/numpy/issues/5173
>
> and the PR is
>
>     https://github.com/numpy/numpy/pull/15121
>
> The new method (as it would be called from Python) is
>
>     permuted(x, axis=None, out=None)
>
I like the proposed API and name personally, and think we should go
ahead with it. It is a useful complement to `shuffle` (and sorting).

The followup questions of adding `shuffled`, and what to do about
`permutation` are important, but I agree with viewing them as a second
step.

This API has been discussed a few times in various depths, so I assume
that `permuted` as a name and API has largely settle down, and reached
consensus (at last if there is not more activity here or on the PR).

So, as a heads up, I am planning to review and push that forward in the
next days, but more discussion is of course welcome. We still have time
to decide differently.

Cheers,

Sebastian


> The CircleCI rendering of the docstring from the pull request is
>
>    
> https://14745-908607-gh.circle-artifacts.com/0/doc/build/html/reference/random/generated/numpy.random.Generator.permuted.html
>
> The new method is an alternative to the existing `shuffle` and
> `permutation` methods.  It handles the `axis` parameter similar
> to how the sort methods do, i.e. when `axis` is given, the slices
> along the axis are shuffled independently.  This new documentation
> (added as part of the pull request) explains the API of the various
> related methods:
>
>    
> https://14745-908607-gh.circle-artifacts.com/0/doc/build/html/reference/random/generator.html#permutations
>
> Additional feedback on the implementation of `permuted` in the
> pull request is welcome.  Further discussion of the API should
> be held in the issue gh-5173 (but please familiarize yourself
> with the discussion of the API in gh-5173--there has already
> been quite a long discussion of several different APIs).
>
> Thanks,
>
> Warren
> _______________________________________________
> NumPy-Discussion mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/numpy-discussion
>

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

signature.asc (849 bytes) Download Attachment