149
149
u2 = UnivariateFinite (v[1 : 2 ], probs, augment= true )
150
150
@test pdf .(u2, v[3 ]) == zeros (3 )
151
151
@test isequal (logpdf .(u2, v[3 ]), log .(zeros (3 )))
152
+
153
+ # # Check that the appropriate errors are thrown
154
+ @test_throws DomainError pdf .(u," strange_level" )
152
155
end
153
156
154
157
_skip (v) = collect (skipmissing (v))
@@ -168,23 +171,23 @@ _skip(v) = collect(skipmissing(v))
168
171
end
169
172
170
173
# # Check that the appropriate errors are thrown
171
- v1 = [v0[1 : end - 1 ];" strange_level" ]
174
+ v1 = categorical ( [v0[1 : end - 1 ];" strange_level" ])
172
175
v2 = [v0... ;rand (rng, v0)] # length(u) !== length(v2)
173
176
@test_throws DimensionMismatch broadcast (pdf, u, v2)
174
177
@test_throws DomainError broadcast (pdf, u, v1)
175
178
176
179
end
177
180
178
- @testset " broadcasting: check indexing in `getter((cv , i), dtype )` see PR#375" begin
181
+ @testset " broadcasting: check indexing in `getter((cv_ref , i))` see PR#375 from MLJBase " begin
179
182
c = categorical ([0 ,1 ,1 ])
180
183
d = UnivariateFinite (c[1 : 1 ], [1 1 1 ]' )
181
184
v = categorical ([0 ,1 ,1 ,1 ])
182
185
@test broadcast (pdf, d, v[2 : end ]) == [0 ,0 ,0 ]
183
186
end
184
187
185
188
@testset " _getindex" begin
186
- @test CategoricalDistributions. _getindex (collect (1 : 4 ), 2 , Int64 ) == 2
187
- @test CategoricalDistributions. _getindex (nothing , 2 , Int64 ) == zero (Int64)
189
+ @test CategoricalDistributions. _getindex (collect (1 : 4 ), 2 ) == 2
190
+ @test CategoricalDistributions. _getindex (0 , 2 ) === 0
188
191
end
189
192
190
193
@testset " broadcasting mode" begin
0 commit comments