@@ -23,18 +23,16 @@ atol = 200
2323 @test isapprox (num_cos, num_samples ÷ 3 ; atol)
2424
2525 # Now, we sample without sharing
26- for break_sharing in (true , Val (true ))
27- broken_sharing_samples = let rng = Random. MersenneTwister (0 )
28- [rand (rng, NodeSampler (; tree, break_sharing)) for _ in 1 : num_samples]
29- end
30- num_plus = count (Base. Fix1 (=== , tree), broken_sharing_samples)
31- num_x = count (Base. Fix1 (=== , x), broken_sharing_samples)
32- num_cos = count (Base. Fix1 (=== , tree. l), broken_sharing_samples)
33-
34- @test isapprox (num_plus, num_samples ÷ 4 ; atol)
35- @test isapprox (num_x, num_samples ÷ 2 ; atol)
36- @test isapprox (num_cos, num_samples ÷ 4 ; atol)
26+ broken_sharing_samples = let rng = Random. MersenneTwister (0 )
27+ [rand (rng, NodeSampler (; tree, break_sharing= Val (true ))) for _ in 1 : num_samples]
3728 end
29+ num_plus = count (Base. Fix1 (=== , tree), broken_sharing_samples)
30+ num_x = count (Base. Fix1 (=== , x), broken_sharing_samples)
31+ num_cos = count (Base. Fix1 (=== , tree. l), broken_sharing_samples)
32+
33+ @test isapprox (num_plus, num_samples ÷ 4 ; atol)
34+ @test isapprox (num_x, num_samples ÷ 2 ; atol)
35+ @test isapprox (num_cos, num_samples ÷ 4 ; atol)
3836end
3937
4038@testset " Weighted sampling" begin
6866 5.0
6967 end
7068 end
71- for break_sharing in (true , Val (true ))
72- broken_sharing_weighted_samples = let rng = Random. MersenneTwister (0 )
73- [
74- rand (rng, NodeSampler (; tree, weighting= weighting_2, break_sharing)) for
75- _ in 1 : num_samples
76- ]
77- end
78- num_plus = count (Base. Fix1 (=== , tree), broken_sharing_weighted_samples)
79- num_x = count (Base. Fix1 (=== , x), broken_sharing_weighted_samples)
80- num_cos = count (Base. Fix1 (=== , tree. l), broken_sharing_weighted_samples)
81-
82- @test isapprox (num_plus, num_samples * 5 ÷ 100 ; atol)
83- @test isapprox (num_x, num_samples * 20 ÷ 100 ; atol)
84- @test isapprox (num_cos, num_samples * 75 ÷ 100 ; atol)
69+ broken_sharing_weighted_samples = let rng = Random. MersenneTwister (0 )
70+ [
71+ rand (rng, NodeSampler (; tree, weighting= weighting_2, break_sharing= Val (true ))) for _ in 1 : num_samples
72+ ]
8573 end
74+ num_plus = count (Base. Fix1 (=== , tree), broken_sharing_weighted_samples)
75+ num_x = count (Base. Fix1 (=== , x), broken_sharing_weighted_samples)
76+ num_cos = count (Base. Fix1 (=== , tree. l), broken_sharing_weighted_samples)
77+
78+ @test isapprox (num_plus, num_samples * 5 ÷ 100 ; atol)
79+ @test isapprox (num_x, num_samples * 20 ÷ 100 ; atol)
80+ @test isapprox (num_cos, num_samples * 75 ÷ 100 ; atol)
8681end
0 commit comments