ENH: Replace "vnl/vnl_sample.h" with <random>, in Core tests - #5611
Merged
hjmjohnson merged 1 commit intoNov 8, 2025
Merged
Conversation
Replaced code like `randomNumber = vnl_sample_uniform(min, max)` with something like:
std::mt19937 randomNumberEngine{};
std::uniform_distribution<T> randomNumberDistribution(min, max);
randomNumber = randomNumberDistribution(randomNumberEngine);
`vnl_sample_uniform` is discouraged, especially because it has a global state
(static data). This problem is addressed by declaring random number engines
as local (non-static) variables, local to the tests that use them.
N-Dekker
force-pushed
the
Replace-vnl_sample_uniform
branch
from
November 8, 2025 12:09
aa8441c to
819856d
Compare
N-Dekker
marked this pull request as ready for review
November 8, 2025 17:21
Contributor
Author
Thanks Hans! There are a few more |
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 10, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 10, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 10, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 10, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 11, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 11, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 11, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 12, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 12, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 12, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
CavRiley
pushed a commit
to CavRiley/ITK
that referenced
this pull request
Dec 23, 2025
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
7 tasks
CavRiley
pushed a commit
to CavRiley/ITK
that referenced
this pull request
Jan 8, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit f7daf24 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests" The random number generator change affected test outputs, requiring updated baseline images as well. Co-authored-by: Niels Dekker <N.Dekker@lumc.nl>
7 tasks
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 0f1dd41 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 0f1dd41 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 0f1dd41 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 0f1dd41 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 0f1dd41 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 0f1dd41 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests" The random number generator change affected test outputs, requiring updated baseline images as well. Co-authored-by: Niels Dekker <N.Dekker@lumc.nl>
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 12, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 2efcc80 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 12, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 2efcc80 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 12, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 2efcc80 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 12, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 2efcc80 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 12, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 2efcc80 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests"
hjmjohnson
pushed a commit
to hjmjohnson/ITK
that referenced
this pull request
May 12, 2026
Follow-up to pull request InsightSoftwareConsortium#5611 commit 2efcc80 "ENH: Replace "vnl/vnl_sample.h" with `<random>`, in Core tests" The random number generator change affected test outputs, requiring updated baseline images as well. Co-authored-by: Niels Dekker <N.Dekker@lumc.nl>
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.
Replaced code like
randomNumber = vnl_sample_uniform(min, max)with something like:vnl_sample_uniformis discouraged, especially because it has a global state (static data). This problem is addressed by declaring random number engines as local (non-static) variables, local to the tests that use them.Obviously, this modernization yields more lines of code than before. While in general, I like it better when modernization yields less code! But I can't help it 🤷 It appears fundamental to modern random number generation to declare separate "engine" and "distribution" variables, instead of just doing a single library function call.