-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: provide numpy.random.shuffle(a, b, ...), 2 arrays in unison #8204
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
Wouldn't it be natural to let |
Take more or same arguments as in sklearn.utils.shuffle is fine. But sklearn.utils.shuffle use the double amount of memory in my test. I'd like the in-place implementation without using 2x times memory of the input arrays. |
There has been no activity here from core devs for more than five years, so I think it is pretty clear that there is no interest in adding such functionality to NumPy. I'm closing the issue, but if it turns out that there is interest, it can be reopened. |
http://stackoverflow.com/questions/4601373/better-way-to-shuffle-two-numpy-arrays-in-unison
numpy.random.shuffle only shuffle 1 array in-place.
It will be better to provide another function to shuffle 2 / multiple arrays in-place, and in unison.
I like the proposed:
def shuffle_in_unison_scary(a, b):
rng_state = numpy.random.get_state()
numpy.random.shuffle(a)
numpy.random.set_state(rng_state)
numpy.random.shuffle(b)
And want numpy guys to confirm this implementation, and add to numpy library itself.
The text was updated successfully, but these errors were encountered: