1
1
# This file is a part of DensityInterface.jl, licensed under the MIT License (MIT).
2
2
3
3
"""
4
- DensityInterface.test_density_interface(d, x, ref_logd_at_x; compare=isapprox, kwargs...)
4
+ DensityInterface.test_density_interface(d, x, ref_logd_at_x; kwargs...)
5
5
6
6
Test if `d` is compatible with `DensityInterface`.
7
7
@@ -13,26 +13,26 @@ Also tests if `logfuncdensity(logdensityof(d))` returns
13
13
a density equivalent to `d` in respect to the functions above.
14
14
15
15
The results of `logdensityof(d, x)` and `densityof(d, x)` are compared to
16
- `ref_logd_at_x` and `exp(ref_logd_at_x)` using `compare `. `kwargs...` are
17
- forwarded to `compare `.
16
+ `ref_logd_at_x` and `exp(ref_logd_at_x)` using `isapprox `. `kwargs...` are
17
+ forwarded to `isapprox `.
18
18
"""
19
- function test_density_interface (d, x, ref_logd_at_x; compare = isapprox, kwargs... )
19
+ function test_density_interface (d, x, ref_logd_at_x; kwargs... )
20
20
@testset " test_density_interface: $d with input $x " begin
21
21
ref_d_at_x = exp (ref_logd_at_x)
22
22
23
23
@test hasdensity (d) == true
24
- @test compare (logdensityof (d, x), ref_logd_at_x; kwargs... )
24
+ @test isapprox (logdensityof (d, x), ref_logd_at_x; kwargs... )
25
25
log_f = logdensityof (d)
26
- @test compare (log_f (x), ref_logd_at_x; kwargs... )
27
- @test compare (densityof (d,x), ref_d_at_x; kwargs... )
28
- @test compare (densityof (d)(x), ref_d_at_x; kwargs... )
26
+ @test isapprox (log_f (x), ref_logd_at_x; kwargs... )
27
+ @test isapprox (densityof (d,x), ref_d_at_x; kwargs... )
28
+ @test isapprox (densityof (d)(x), ref_d_at_x; kwargs... )
29
29
30
30
d2 = logfuncdensity (log_f)
31
31
@test hasdensity (d2) == true
32
- @test compare (logdensityof (d2, x), ref_logd_at_x; kwargs... )
32
+ @test isapprox (logdensityof (d2, x), ref_logd_at_x; kwargs... )
33
33
log_f2 = logdensityof (d2)
34
- @test compare (log_f2 (x), ref_logd_at_x; kwargs... )
35
- @test compare (densityof (d2,x), ref_d_at_x; kwargs... )
36
- @test compare (densityof (d2)(x), ref_d_at_x; kwargs... )
34
+ @test isapprox (log_f2 (x), ref_logd_at_x; kwargs... )
35
+ @test isapprox (densityof (d2,x), ref_d_at_x; kwargs... )
36
+ @test isapprox (densityof (d2)(x), ref_d_at_x; kwargs... )
37
37
end
38
38
end
0 commit comments