Skip to content

Commit 20030fd

Browse files
committed
rename Distribution[N] -> Combine[N] for combined objects
1 parent a3b4c26 commit 20030fd

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

base/random/random.jl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,28 @@ abstract type Distribution{T} end
3131

3232
Base.eltype(::Type{Distribution{T}}) where {T} = T
3333

34-
struct Distribution0{T} <: Distribution{T} end
34+
abstract type Combine{T} <: Distribution{T} end
3535

36-
Distribution(::Type{T}) where {T} = Distribution0{T}()
36+
struct Combine0{T} <: Combine{T} end
3737

38-
struct Distribution1{T,X} <: Distribution{T}
38+
Combine(::Type{T}) where {T} = Combine0{T}()
39+
40+
struct Combine1{T,X} <: Combine{T}
3941
x::X
4042
end
4143

42-
Distribution(::Type{T}, x::X) where {T,X} = Distribution1{T,X}(x)
43-
Distribution(::Type{T}, ::Type{X}) where {T,X} = Distribution1{T,Type{X}}(X)
44+
Combine(::Type{T}, x::X) where {T,X} = Combine1{T,X}(x)
45+
Combine(::Type{T}, ::Type{X}) where {T,X} = Combine1{T,Type{X}}(X)
4446

45-
struct Distribution2{T,X,Y} <: Distribution{T}
47+
struct Combine2{T,X,Y} <: Combine{T}
4648
x::X
4749
y::Y
4850
end
4951

50-
Distribution(::Type{T}, x::X, y::Y) where {T,X,Y} = Distribution2{deduce_type(T,X,Y),X,Y}(x, y)
51-
Distribution(::Type{T}, ::Type{X}, y::Y) where {T,X,Y} = Distribution2{deduce_type(T,X,Y),Type{X},Y}(X, y)
52-
Distribution(::Type{T}, x::X, ::Type{Y}) where {T,X,Y} = Distribution2{deduce_type(T,X,Y),X,Type{Y}}(x, Y)
53-
Distribution(::Type{T}, ::Type{X}, ::Type{Y}) where {T,X,Y} = Distribution2{deduce_type(T,X,Y),Type{X},Type{Y}}(X, Y)
52+
Combine(::Type{T}, x::X, y::Y) where {T,X,Y} = Combine2{deduce_type(T,X,Y),X,Y}(x, y)
53+
Combine(::Type{T}, ::Type{X}, y::Y) where {T,X,Y} = Combine2{deduce_type(T,X,Y),Type{X},Y}(X, y)
54+
Combine(::Type{T}, x::X, ::Type{Y}) where {T,X,Y} = Combine2{deduce_type(T,X,Y),X,Type{Y}}(x, Y)
55+
Combine(::Type{T}, ::Type{X}, ::Type{Y}) where {T,X,Y} = Combine2{deduce_type(T,X,Y),Type{X},Type{Y}}(X, Y)
5456

5557
deduce_type(::Type{T}, ::Type{X}, ::Type{Y}) where {T,X,Y} = _deduce_type(T, Val(isconcrete(T)), eltype(X), eltype(Y))
5658
deduce_type(::Type{T}, ::Type{X}) where {T,X} = _deduce_type(T, Val(isconcrete(T)), eltype(X))
@@ -91,7 +93,7 @@ end
9193
Exponential(::Type{T}=Float64) where {T<:AbstractFloat} = Exponential1{T}()
9294
Exponential::T) where {T<:AbstractFloat} = Exponentialθ(θ)
9395

94-
### floats
96+
#### floats
9597

9698
abstract type FloatInterval{T<:AbstractFloat} <: Uniform{T} end
9799
abstract type CloseOpen{T<:AbstractFloat} <: FloatInterval{T} end
@@ -119,6 +121,7 @@ Base.eltype(::Type{<:FloatInterval{T}}) where {T<:AbstractFloat} = T
119121

120122
const BitFloatType = Union{Type{Float16},Type{Float32},Type{Float64}}
121123

124+
122125
### Sampler
123126

124127
abstract type Sampler{E} end

0 commit comments

Comments
 (0)