-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Description
At the moment the error messages are all over the place and highly inconsistent. For example the assume function in HMC uses three different types of error messages.
Turing.jl/src/inference/hmc.jl
Line 278 in 3f72f12
@assert length(dists) == 1 "[observe] Turing only support vectorizing i.i.d distribution" Turing.jl/src/inference/hmc.jl
Line 298 in 3f72f12
@assert size(var) == size(rs) "Turing.assume variable and random number dimension unmatched" Turing.jl/src/inference/hmc.jl
Line 301 in 3f72f12
error("[Turing] unsupported variable container")
I think we should have a consistent way of doing this. Maybe we can have a simple function that generates those error messages, e.g.
tmsg(msg::AbstractString, scope:: AbstractString) = "Turing [$scope]: $msg"which would be used as follows:
@assert length(dists) == 1 tmsg("Turing only support vectorizing i.i.d distribution", "HMC.assume")
@assert size(var) == size(rs) tmsg("Variable and random number dimension unmatched.", "HMC.assume")
error("Unsupported variable container", "HMC.assume")I guess we could also write a macro for this but I'm not sure its worth the efforts.
Metadata
Metadata
Assignees
Labels
No labels