Skip to content

Commit d23645a

Browse files
authored
logdensityof should throw ArgumentError for non-density arg (#7)
1 parent 7c4718a commit d23645a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export hasdensity
1919
@inline hasdensity(::Any) = false
2020

2121
function check_hasdensity(d)
22-
hasdensity(d) || throw("Object of type $(typeof(d)) is not compatible with DensityInterface")
22+
hasdensity(d) || throw(ArgumentError("Object of type $(typeof(d)) is not compatible with DensityInterface"))
2323
end
2424

2525

test/test_interface.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ DensityInterface.logdensityof(::MyDensity, x::Any) = norm(x)^2
1616
@test inverse(logfuncdensity) == logdensityof
1717

1818
@test @inferred(hasdensity("foo")) == false
19+
@test_throws ArgumentError logdensityof("foo")
1920

2021
d1 = MyDensity()
2122
x = [1, 2, 3]

0 commit comments

Comments
 (0)