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

Revise sp_manager::global_shuffle #1933

Open
heplesser opened this issue Feb 22, 2021 · 5 comments
Open

Revise sp_manager::global_shuffle #1933

heplesser opened this issue Feb 22, 2021 · 5 comments
Assignees
Labels
good first issue Good for newcomers I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority stale Automatic marker for inactivity, please have another look here T: Maintenance Work to keep up the quality of the code and documentation.

Comments

@heplesser
Copy link
Contributor

Currently, the behavior of sp_manager::global_shuffle() does not agree with the comment describing the method:

  • The comment states that the method "shuffles the first n elements of the vector", implying that the elements from n+1 on remain in the vector in original order
  • The method randomly picks n elements from the entire vector without replacement and then replaces the content of the vector with these first n elements, dropping the rest

The way the method is used (eg here

global_shuffle( pre_id_rnd, post_id_rnd.size() );
pre_id_rnd.resize( post_id_rnd.size() );
) indicates that the actual behavior is what is intended (but the resize() after calling the method is then not necessary).

Comment and code need to be brought into agreement. One might also consider a more informative method name, including the "chopping" part. The implementation should be reviewed as well. It should be able to work in-place without need of the "erase" function (costly). It might make sense to use suitable C++11 functions, e.g. https://www.cplusplus.com/reference/algorithm/random_shuffle/. Finally, variable names in the method are very uninformative and should be revised.

@heplesser heplesser added S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation. I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) good first issue Good for newcomers labels Feb 22, 2021
@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Issue automatically marked stale!

@github-actions github-actions bot added the stale Automatic marker for inactivity, please have another look here label Sep 3, 2021
@heplesser
Copy link
Contributor Author

@sdiazpier @pnbabu Ping!

@github-actions github-actions bot removed the stale Automatic marker for inactivity, please have another look here label Apr 23, 2022
@pradkrish
Copy link

Hello, Is this issue still open? I am happy to give it a go.

@heplesser
Copy link
Contributor Author

heplesser commented May 18, 2022

Yes, the issue appears still to be open.

@github-actions
Copy link

Issue automatically marked stale!

@github-actions github-actions bot added the stale Automatic marker for inactivity, please have another look here label Nov 30, 2022
@jessica-mitchell jessica-mitchell moved this to To do in Models Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority stale Automatic marker for inactivity, please have another look here T: Maintenance Work to keep up the quality of the code and documentation.
Projects
Status: To do
Development

No branches or pull requests

4 participants