Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xukai92 committed Sep 20, 2019
1 parent 8f2112f commit 4cd4e23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/moment_matching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ function _estimate_ratio(mmd::MMDNumerical, Kdede, Kdenu)
return value.(r)
end

struct MMDAnalytical{T,S,M} <: AbstractMMD
struct MMDAnalytical{T<:AbstractFloat,S,M} <: AbstractMMD
ϵ::T
function MMDAnalytical(; ϵ::T=1f-3, method::Symbol=:solve) where {T<:AbstractFloat}
function MMDAnalytical(; ϵ::T=1f-3, method::Symbol=:solve) where {T}
@assert method in (:solve, :inv)
S = iszero(ϵ) ? Val{:false} : Val{:true}
new{T, S, Val{method}}(ϵ)
if T == Int
ϵ = float(ϵ)
end
new{eltype(ϵ), S, Val{method}}(ϵ)
end
end

Expand Down
5 changes: 5 additions & 0 deletions test/moment_matching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ end

r_solve = estimate_ratio(MMDAnalytical(method=:solve), x_de, x_nu)
r_inv = estimate_ratio(MMDAnalytical(method=:inv), x_de, x_nu)

@test r_solve r_inv

r_solve = estimate_ratio(MMDAnalytical=0), x_de, x_nu)
r_inv = estimate_ratio(MMDAnalytical=0), x_de, x_nu)

@test r_solve r_inv
end
Expand Down

0 comments on commit 4cd4e23

Please sign in to comment.