Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkCI = "20533458-34a3-403d-a444-e18f38190b5b"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Coverage = "a2441757-f6aa-5fb2-8edb-039e3f45d037"
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand All @@ -89,9 +90,10 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04"

[targets]
test = ["Test", "Pkg", "Logging", "InteractiveUtils", "TestSetExtensions", "Coverage", "Dates", "Distributed", "Documenter", "BenchmarkCI", "BenchmarkTools", "PkgBenchmark", "Aqua", "StableRNGs", "Optimisers", "DiffResults"]
test = ["Aqua", "CpuId", "ReTestItems", "Test", "Pkg", "Logging", "InteractiveUtils", "TestSetExtensions", "Coverage", "Dates", "Distributed", "Documenter", "BenchmarkCI", "BenchmarkTools", "PkgBenchmark", "StableRNGs", "Optimisers", "DiffResults"]
9 changes: 2 additions & 7 deletions test/addons/test_debug.jl → test/addons/debug_tests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module ReactiveMPAddonsDebugTest

using Test, ReactiveMP, Distributions, BayesBase, ExponentialFamily

@testset "Debug addon" begin
@testitem "Debug addon" begin
using ExponentialFamily, BayesBase
import ReactiveMP: AddonDebug

@testset "Creation" begin
Expand All @@ -20,5 +17,3 @@ using Test, ReactiveMP, Distributions, BayesBase, ExponentialFamily
@test multiply_addons(addon, addon, NormalMeanVariance(0.0, 3.00), Missing(), Missing()) == addon
end
end

end
8 changes: 2 additions & 6 deletions test/addons/test_memory.jl → test/addons/memory_tests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module ReactiveMPAddonsMemoryTest
@testitem "Memory addon" begin
using ExponentialFamily, BayesBase

using Test, ReactiveMP, Distributions, BayesBase, ExponentialFamily

@testset "Memory addon" begin
import ReactiveMP: AddonMemory

@testset "Creation" begin
Expand Down Expand Up @@ -35,5 +33,3 @@ using Test, ReactiveMP, Distributions, BayesBase, ExponentialFamily
@test occursin("result: $(repr(result))", displayed)
end
end

end
10 changes: 3 additions & 7 deletions test/test_addons.jl → test/addons_tests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

module ReactiveMPAddonsTest
@testitem "Addons" begin
using ReactiveMP, BayesBase, Distributions, ExponentialFamily

using Test, ReactiveMP, BayesBase, Distributions, ExponentialFamily
using ReactiveMP: multiply_addons

using ReactiveMP: multiply_addons

@testset "Addons" begin
@testset "addonlogscale" begin
@testset "creation" begin
addon1 = AddonLogScale()
Expand Down Expand Up @@ -41,5 +39,3 @@ using ReactiveMP: multiply_addons
end
end
end

end
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
module ReactiveMPRenderCVITest

using Test, ReactiveMP, Random, StableRNGs, BayesBase, Distributions, ExponentialFamily, Optimisers, DiffResults, LinearAlgebra
@testitem "cvi:prod" begin
using ReactiveMP, Random, StableRNGs, BayesBase, Distributions, ExponentialFamily, Optimisers, DiffResults, LinearAlgebra

import BayesBase: AbstractContinuousGenericLogPdf
import StatsFuns: logistic, softmax
import SpecialFunctions: polygamma
import BayesBase: AbstractContinuousGenericLogPdf
import StatsFuns: logistic, softmax
import SpecialFunctions: polygamma

struct NoopOptimiser end
struct NoopOptimiser end

function ReactiveMP.cvi_setup(::NoopOptimiser, λ)
return (NoopOptimiser(), nothing)
end

function ReactiveMP.cvi_update!(state::Tuple{NoopOptimiser, Nothing}, new_λ, λ, ∇)
return state, vec(λ)
end
function ReactiveMP.cvi_setup(::NoopOptimiser, λ)
return (NoopOptimiser(), nothing)
end

mutable struct CountingOptimizer
num_its::Int
end
function ReactiveMP.cvi_update!(state::Tuple{NoopOptimiser, Nothing}, new_λ, λ, ∇)
return state, vec(λ)
end

function ReactiveMP.cvi_setup(opt::CountingOptimizer, λ)
return (opt, nothing)
end
mutable struct CountingOptimizer
num_its::Int
end

function ReactiveMP.cvi_update!(state::Tuple{CountingOptimizer, Nothing}, new_λ, λ, ∇)
opt = state[1]
opt.num_its += 1
return (state, vec(λ))
end
function ReactiveMP.cvi_setup(opt::CountingOptimizer, λ)
return (opt, nothing)
end

function gammafisher(dist::GammaShapeRate)
return [polygamma(1, shape(dist)) -1/rate(dist); -1/rate(dist) shape(dist)/rate(dist)^2]
end
function ReactiveMP.cvi_update!(state::Tuple{CountingOptimizer, Nothing}, new_λ, λ, ∇)
opt = state[1]
opt.num_its += 1
return (state, vec(λ))
end

@testset "cvi:prod" begin
function gammafisher(dist::GammaShapeRate)
return [polygamma(1, shape(dist)) -1/rate(dist); -1/rate(dist) shape(dist)/rate(dist)^2]
end

# These are tested in the `ExponentialFamily`, test a simple case just to be sure
@testset "Simple check for the existence of the `fisherinformation`" begin
Expand Down Expand Up @@ -197,4 +195,3 @@ end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module ReactiveMPLinearizationApproximationTest

using Test
using ReactiveMP
@testitem "Linearization approximation method" begin
using ReactiveMP

import ReactiveMP: Linearization
import ReactiveMP: Linearization

@testset "Linearization approximation method" begin
@testset "linearization `approximate` tests" begin
import ReactiveMP: approximate, Linearization

Expand All @@ -15,5 +13,3 @@ import ReactiveMP: Linearization
@test @inferred(approximate(Linearization(), (x, y) -> x .- y, ([1.0, 2.0], [1.0, 1.0]))) == ([1.0 0.0 -1.0 0.0; 0.0 1.0 0.0 -1.0], [0.0, 0.0])
end
end

end
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module ReactiveMPSharedApproximationTest

using Test
using ReactiveMP
@testitem "Shared approximation methods" begin
using ReactiveMP

@testset "Shared approximation methods" begin
@testset "__starts_at tests" begin
import ReactiveMP: __starts_at

Expand Down Expand Up @@ -52,5 +50,3 @@ using ReactiveMP
@test @inferred(__splitjoin([1, 0, 0, 1, 2, 1, 0, 0, 1], ((2, 2), (), (2, 2)))) == ([1 0; 0 1], 2, [1 0; 0 1])
end
end

end
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module ReactiveMPUnscentedApproximationTest

using Test
using ReactiveMP
@testitem "Unscented approximation method" begin
using ReactiveMP

import ReactiveMP: Unscented, unscented_statistics
import ReactiveMP: Unscented, unscented_statistics

@testset "Unscented approximation method" begin
@testset "Univariate `unscented_statistics`" begin

# Compared against the ForneyLab implementation
Expand Down Expand Up @@ -78,5 +76,3 @@ import ReactiveMP: Unscented, unscented_statistics
)
end
end

end
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
module ReactiveMPFactorisationSpecTest

using Test
using ReactiveMP
@testitem "Factorisation constraints specification" begin
using ReactiveMP

import ReactiveMP: FunctionalIndex
import ReactiveMP: CombinedRange, SplittedRange, is_splitted
import ReactiveMP: __as_unit_range, __factorisation_specification_resolve_index
import ReactiveMP: resolve_factorisation
import ReactiveMP: DefaultConstraints, UnspecifiedConstraints
import ReactiveMP: setanonymous!, activate!
import ReactiveMP: FunctionalIndex
import ReactiveMP: CombinedRange, SplittedRange, is_splitted
import ReactiveMP: __as_unit_range, __factorisation_specification_resolve_index
import ReactiveMP: resolve_factorisation
import ReactiveMP: DefaultConstraints, UnspecifiedConstraints
import ReactiveMP: setanonymous!, activate!

@testset "Factorisation constraints specification" begin
@testset "CombinedRange" begin
for left in 1:3, right in 10:13
cr = CombinedRange(left, right)
Expand Down Expand Up @@ -108,5 +106,3 @@ import ReactiveMP: setanonymous!, activate!
)
end
end

end
12 changes: 4 additions & 8 deletions test/constraints/test_meta.jl → test/constraints/meta_tests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module ReactiveMPFactorisationSpecTest
@testitem "Meta specification" begin
using ReactiveMP, BayesBase, ExponentialFamily

using Test, ReactiveMP, BayesBase, ExponentialFamily
import ReactiveMP: MetaSpecification, MetaSpecificationOptions, MetaSpecificationEntry
import ReactiveMP: resolve_meta

import ReactiveMP: MetaSpecification, MetaSpecificationOptions, MetaSpecificationEntry
import ReactiveMP: resolve_meta

@testset "Meta specification" begin
@testset "resolve_meta #1" begin
spec = MetaSpecification(
(
Expand Down Expand Up @@ -80,5 +78,3 @@ import ReactiveMP: resolve_meta
@test_throws ErrorException resolve_meta(spec, NormalMeanPrecision, (randomvar(:z), randomvar(:x)))
end
end

end
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module AlgebraCommonTest

using Test
using ReactiveMP
using Random
using LinearAlgebra
@testitem "AlgebraCommonTest" begin
using ReactiveMP
using Random
using LinearAlgebra

@testset "Common" begin
@testset "negate_inplace!" begin
rng = MersenneTwister(1234)

Expand Down Expand Up @@ -95,5 +93,3 @@ using LinearAlgebra
end
end
end

end
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module ReactiveMPPermutationMatrixTest
@testitem "Permutation Matrix" begin
using ReactiveMP
using ReactiveMP: getind, PT_X_P
using Random

using Test
using ReactiveMP
using ReactiveMP: getind, PT_X_P
using Random
using LinearAlgebra

using LinearAlgebra

@testset "Permutation Matrix" begin
@testset "Creation" begin
ind = shuffle(collect(1:100))
P = PermutationMatrix(ind)
Expand Down Expand Up @@ -118,4 +115,3 @@ using LinearAlgebra
@test PT_X_P(X, P) == P_dense' * X * P_dense
end
end
end
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
module ReactiveMPStandardBasisVectorTest
@testitem "StandardBasisVector" begin
using ReactiveMP
using Random

using Test
using ReactiveMP
using Random
using LinearAlgebra

using LinearAlgebra

@testset "StandardBasisVector" begin
rng = MersenneTwister(1234)

@testset begin
Expand Down Expand Up @@ -132,5 +129,3 @@ using LinearAlgebra
end
end
end

end
15 changes: 5 additions & 10 deletions test/helpers/test_helpers.jl → test/helpers/helpers_tests.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module ReactiveMPTestingHelpers
@testitem "Helpers" begin
using ReactiveMP

using Test
using ReactiveMP
import ReactiveMP: SkipIndexIterator, skipindex
import ReactiveMP: CountingReal
import ReactiveMP: FunctionalIndex

import ReactiveMP: SkipIndexIterator, skipindex
import ReactiveMP: CountingReal
import ReactiveMP: FunctionalIndex

@testset "Helpers" begin
@testset "SkipIndexIterator" begin
s = skipindex(1:3, 2)
@test typeof(s) <: SkipIndexIterator
Expand Down Expand Up @@ -42,5 +39,3 @@ import ReactiveMP: FunctionalIndex
@test isbitstype(typeof((FunctionalIndex{:begin}(firstindex) - 1 + 1)))
end
end

end
19 changes: 8 additions & 11 deletions test/test_message.jl → test/message_tests.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module ReactiveMPMessageTest

using Test, Random, ReactiveMP, BayesBase, Distributions, ExponentialFamily
@testitem "Message" begin
using Random, ReactiveMP, BayesBase, Distributions, ExponentialFamily

import InteractiveUtils: methodswith
import Base: methods
import Base.Iterators: repeated, product
import BayesBase: xtlog, mirrorlog
import ReactiveMP: getaddons, multiply_messages, materialize!
import SpecialFunctions: loggamma
import InteractiveUtils: methodswith
import Base: methods
import Base.Iterators: repeated, product
import BayesBase: xtlog, mirrorlog
import ReactiveMP: getaddons, multiply_messages, materialize!
import SpecialFunctions: loggamma

@testset "Message" begin
@testset "Default methods" begin
data = PointMass(1)

Expand Down Expand Up @@ -161,5 +160,3 @@ import SpecialFunctions: loggamma
end
end
end

end
Loading