-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
@testset
: with Xoshiro, restore Random.GLOBAL_SEED
#43188
Conversation
Does this possibly fix #42752? |
Probably not, but who knows?... I noticed the bug fixed by this PR while looking at that issue, but I don't understand the cause of it. |
A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately.
f688f41
to
e53b1b9
Compare
@test GLOBAL_SEED_orig == Random.GLOBAL_SEED | ||
@testset "GLOBAL_SEED is also preserved (beginend)" begin | ||
@test refvalue == rand(Int) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end | |
end | |
@test GLOBAL_SEED_orig == Random.GLOBAL_SEED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes this could be added, but this is also tested after the first testset of the series, which is also "beginend" (actually, this last testset really is testing that the forloop one correctly restored the global seed by checking rand(Int)
within it, but it's a bit redundant with @test GLOBAL_SEED_orig == Random.GLOBAL_SEED
just before it; but as we don't call seed!
there, there is not much need to recheck this equality after it).
Would it be better if we called |
It would work too, but we would indeed need to still make the copy to restore the global rng, which doesn't necessarily correspond to the pristine state after |
Does this bug need to be fixed inside |
No, |
A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately. (cherry picked from commit 08ea2d8)
A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately. (cherry picked from commit 08ea2d8)
A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately. (cherry picked from commit 08ea2d8)
A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately.
A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately.
…#43188) A `@testset` is supposed to restore the "global RNG state" as it was before execution (so that they can be re-ordered easily, etc.) Also, before a testset starts, the default RNG is re-seeded with the "global seed" (to help reproduce test failures). Before `Xoshiro` as the default RNG, the "global seed" was stored within a `MersenneTwister` object. It was enough for a testset to copy the default RNG at the start, and copy it back at the end. But now the global seed is stored outside of the RNG, so it should also be restored separately. (cherry picked from commit 6b48dc1)
A
@testset
is supposed to restore the "global RNG state" asit was before execution (so that they can be re-ordered easily, etc.)
Also, before a testset starts, the default RNG is re-seeded with the
"global seed" (to help reproduce test failures).
Before
Xoshiro
as the default RNG, the "global seed" was storedwithin a
MersenneTwister
object. It was enough for a testset tocopy the default RNG at the start, and copy it back at the end.
But now the global seed is stored outside of the RNG, so it should
also be restored separately.