From 4b1e7533ef1e02ec624dd98b3d8b38346af77b8a Mon Sep 17 00:00:00 2001 From: Mykola Lukashchuk Date: Wed, 24 Jul 2024 11:29:40 +0200 Subject: [PATCH] test: improve tests --- test/distributions/categorical_tests.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/distributions/categorical_tests.jl b/test/distributions/categorical_tests.jl index e81de8d6..0f3cf7e3 100644 --- a/test/distributions/categorical_tests.jl +++ b/test/distributions/categorical_tests.jl @@ -90,9 +90,16 @@ end @testitem "Categorical ExponentialFamilyDistribution supports RecursiveArrayTools" begin using RecursiveArrayTools include("distributions_setuptests.jl") - ef = ExponentialFamilyDistribution(Categorical, ArrayPartition([0, 1, 0]), 3, nothing) - part_ef = ExponentialFamilyDistribution(Categorical, ArrayPartition([0, 1], [0]), 3, nothing) - @test convert(Distribution, ef) ≈ convert(Distribution, part_ef) + for s in (2, 3, 4, 5) + @testset let params = rand(s-1) + ef = ExponentialFamilyDistribution(Categorical, [params..., 0], s, nothing) + part_ef = ExponentialFamilyDistribution(Categorical, ArrayPartition(params, [0]), s, nothing) + @test convert(Distribution, ef) ≈ convert(Distribution, part_ef) + @test mean(ef) ≈ mean(part_ef) + @test var(ef) ≈ var(part_ef) + @test logpartition(ef) ≈ logpartition(part_ef) + end + end end @testitem "Categorical: prod with ExponentialFamilyDistribution" begin