@@ -7,6 +7,7 @@ using StableRNGs
7
7
using FillArrays
8
8
using ScientificTypes
9
9
import Random
10
+ import CategoricalDistributions: classes
10
11
11
12
# coverage of constructor testing is expanded in the other test files
12
13
36
37
37
38
UnivariateFinite (supp, probs, pool= missing , augment= true );
38
39
40
+ # construction from pool and support does not
41
+ # consist of categorical elements (See issue #34)
42
+ v = categorical ([" x" , " x" , " y" , " z" , " y" , " z" , " p" ])
43
+ probs1 = [0.1 , 0.2 , 0.7 ]
44
+ probs2 = [0.1 0.2 0.7 ; 0.5 0.2 0.3 ; 0.8 0.1 0.1 ]
45
+ unf1 = UnivariateFinite ([" y" , " x" , " z" ], probs1, pool= v)
46
+ unf2 = UnivariateFinite ([" y" , " x" , " z" ], probs2, pool= v)
47
+ @test CategoricalArrays. pool (classes (unf1)) == CategoricalArrays. pool (v)
48
+ @test CategoricalArrays. pool (classes (unf2)) == CategoricalArrays. pool (v)
49
+ @test pdf .(unf1, [" y" , " x" , " z" ]) == probs1
50
+ @test pdf .(unf2, " y" ) == probs2[:, 1 ]
51
+ @test pdf .(unf2, " x" ) == probs2[:, 2 ]
52
+ @test pdf .(unf2, " z" ) == probs2[:, 3 ]
53
+
39
54
# dimension mismatches:
40
55
badprobs = rand (rng, 40 , 3 )
41
56
@test_throws (CategoricalDistributions. err_dim (supp, badprobs),
0 commit comments