-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
random choice should support multidimensional arrays #2724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This should be simple if you are thinking about doing it. All that seems necessary is to add a special check for Actually thinking about it, it could also be reasonable to have One could think about also allowing an |
Backwards compatible by adding an `axis` keyword to the end of the signature for choice. Default is 0, which selects by row. The default keyword arguments make it functionally equivalent to random.choice from Python's standard library. Note, however, that a list of tuples will have the tuples returned as lists. Issue numpy#2724 was originally opened with that request, but numpy#2727 seems to have closed it accidentally.
+1 |
+1. Is this still not implemented? |
+1 |
Is this implemented? |
Is this ever going to be implemented? |
+1 |
Added keyword argument axis to the random.choice function that extends its functionality to N-d arrays. Added additional documentation for this feature and checks to ensure that the sizes match. Originally suggested in numpy#2724 Additional checks and documentation Add tests
+1 |
Implemented in the new randomgen API: |
random.choice enhancement request:
random.choice should support multidimensional arrays by taking an axis number. With this enhancement, axis=None would choose from a flattened array, while an integer argument would chose from the subarrays along that axis.
Apologies if this is a duplicate. My previous submission seems to have vanished.
The text was updated successfully, but these errors were encountered: