Skip to content
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

Add axis option to numpy.random.shuffle #11583

Closed
CyanoKobalamyne opened this issue Jul 17, 2018 · 4 comments
Closed

Add axis option to numpy.random.shuffle #11583

CyanoKobalamyne opened this issue Jul 17, 2018 · 4 comments

Comments

@CyanoKobalamyne
Copy link

Currently, numpy.random.shuffle only supports shuffling along the first axis only. Many other Numpy functions support the axis keyword argument to specify the axis along which the respective operation should be applied, it would be great to have such an argument for this function as well.

@subhrm
Copy link
Contributor

subhrm commented Jul 20, 2018

I would suggest apply_along_axis . PFB an example :

import numpy as np
a = np.arange(40).reshape((5,8))       
# shuffle along axis 1     
np.apply_along_axis(np.random.shuffle,1,a) 
# shuffle along axis 0
np.random.shuffle(a)
print(a)

Example output:

[[28 24 30 27 31 25 26 29]
 [39 36 37 33 38 35 34 32]
 [ 9 15 12  8 14 13 11 10]
 [22 17 23 19 20 16 18 21]
 [ 2  1  5  4  6  0  7  3]]

@WarrenWeckesser
Copy link
Member

FYI: #5173

@wkschwartz
Copy link

Can this be closed now because of #13829?

@CyanoKobalamyne
Copy link
Author

I believe so. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants