STYLE: Use generate in tests, assigning values from vnl_sample_uniform - #5608
Merged
hjmjohnson merged 1 commit intoNov 7, 2025
Conversation
Did find code like:
v[0] = static_cast<T>(vnl_sample_uniform(a, b));
v[1] = static_cast<T>(vnl_sample_uniform(a, b));
v[2] = static_cast<T>(vnl_sample_uniform(a, b));
And replaced it with the equivalent `std::generate` call:
std::generate(v.begin(), v.end(), [] {
return static_cast<T>(vnl_sample_uniform(a, b));
});
Aims to reduce code redundancy.
dzenanz
approved these changes
Nov 7, 2025
N-Dekker
marked this pull request as ready for review
November 7, 2025 15:26
hjmjohnson
approved these changes
Nov 7, 2025
Member
|
@N-Dekker It would be good to start deprecating the exposure of vnl capabilities when better alternatives exist. |
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did find code like:
And replaced it with the equivalent
std::generatecall:Aims to reduce code redundancy.
Motivation: in a follow-up I would like those
vnl_sample_uniformcalls to be replaced with modern C++ random number generation. This pull request should pave the way.