8000 ENH: provide numpy.random.shuffle(a, b, ...), 2 arrays in unison · Issue #8204 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
mw66 opened this issue Oct 23, 2016 · 4 comments
Closed

ENH: provide numpy.random.shuffle(a, b, ...), 2 arrays in unison #8204

mw66 opened this issue Oct 23, 2016 · 4 comments

Comments

@mw66
Copy link
mw66 commented Oct 23, 2016

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.

@wrwrwr
Copy link
Contributor
wrwrwr commented Oct 24, 2016

Wouldn't it be natural to let random.shuffle take more arguments as in sklearn.utils.shuffle? Wouldn't the RandomState need to be made thread-local (or accessing the state and shuffling done under GIL)?

@mw66
Copy link
Author
mw66 commented Oct 24, 2016

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.

@andanis
Copy link
andanis commented Nov 29, 2016

http://rasbt.github.io/mlxtend/user_guide/preprocessing/shuffle_arrays_unison/

@mattip mattip changed the title enhancement: provide numpy.random.shuffle(a, b, ...), 2 arrays in unison ENH: provide numpy.random.shuffle(a, b, ...), 2 arrays in unison Jul 19, 2018
@WarrenWeckesser
Copy link
Member

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.

@WarrenWeckesser WarrenWeckesser closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2022
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
0