Skip to content

Commit 3050f01

Browse files
committed
add few comments
1 parent 4d770b3 commit 3050f01

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

base/random/RNGs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## RandomDevice
44

5-
# SamplerTypes(Union{X,Y,...}) = Union{SamplerType{X},SamplerType{Y},...}
5+
# SamplerTypes(Union{X,Y,...}) == Union{SamplerType{X},SamplerType{Y},...}
66
SamplerTypes(U::Union) = Union{map(T->SamplerType{T}, Base.uniontypes(U))...}
77
const SamplerBoolBitInteger = SamplerTypes(Union{Bool, Base.BitInteger})
88

base/random/generation.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
# Uniform random generation
44

5+
# This file contains the creation of Sampler objects and the associated generation of
6+
# random values from them. More specifically, given the specification S of a set
7+
# of values to pick from (e.g. 1:10, or "a string"), we define
8+
#
9+
# 1) Sampler(rng, S, ::Repetition) -> sampler
10+
# 2) rand(rng, sampler) -> random value
11+
#
12+
# Note that the 1) is automated when when the sampler is not intended to carry information,
13+
# i.e. the default fall-backs SamplerType and SamplerTrivial are used.
14+
15+
516
## from types: rand(::Type, [dims...])
617

718
### random floats

base/random/random.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ Base.getindex(st::SamplerSimple) = st.self
9595

9696
### machinery for generation with Sampler
9797

98+
# This describes how to generate random scalars or arrays, by generating a Sampler
99+
# and calling rand on it (which should be defined in "generation.jl").
100+
# NOTE: this section could be moved into a separate file when more containers are supported.
101+
98102
#### scalars
99103

100104
rand(rng::AbstractRNG, X) = rand(rng, Sampler(rng, X, Val(1)))

0 commit comments

Comments
 (0)