- 
                Notifications
    
You must be signed in to change notification settings  - Fork 37
 
Closed
Description
Code:
begin
	import Pkg
	Pkg.activate(temp=true)
	Pkg.add(name="Turing", version="0.16.0", io=devnull)
	Pkg.add(name="Distributions", io=devnull)
	Pkg.status()
end
using Turing, Distributions
@model function(data::AbstractVector)	
	p ~ Dirichlet(2, 1.0)
	μ1 ~ Normal(-4e-4, 2.1e-4)
	μ2 ~ Normal( 4e-4, 2.1e-4)
	
	Σ ~ filldist(Uniform(0, 2.1e-4), 2)
	
	data ~ filldist(
		UnivariateGMM([μ1, μ2], Σ, p),
		length(data)
	)
endError:
~/test $ julia turing_bug2.jl
  Activating new environment at `/var/folders/ys/3h0gnqns4b98zb66_vl_m35m0000gn/T/jl_nVue8d/Project.toml`
      Status `/private/var/folders/ys/3h0gnqns4b98zb66_vl_m35m0000gn/T/jl_nVue8d/Project.toml`
  [31c24e10] Distributions v0.25.2
  [fce5fe82] Turing v0.16.0
ERROR: LoadError: LoadError: KeyError: key :name not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, Any}, key::Symbol)
   @ Base ./dict.jl:482
 [2] build_output(modelinfo::Dict{Symbol, Any}, linenumbernode::LineNumberNode)
   @ DynamicPPL ~/.julia/packages/DynamicPPL/emAbx/src/compiler.jl:385
 [3] model(mod::Module, linenumbernode::LineNumberNode, expr::Expr, warn::Bool)
   @ DynamicPPL ~/.julia/packages/DynamicPPL/emAbx/src/compiler.jl:91
 [4] var"@model"(__source__::LineNumberNode, __module__::Module, expr::Any, warn::Any) (repeats 2 times)
   @ DynamicPPL ~/.julia/packages/DynamicPPL/emAbx/src/compiler.jl:82
in expression starting at /Users/forcebru/test/turing_bug2.jl:12
in expression starting at /Users/forcebru/test/turing_bug2.jl:12
~/test [1] $
I literally spent 15 minutes trying to understand what was wrong. Turns out, I was using too much R lately, and @model function(data::AbstractVector) should've been @model function model_name(data::AbstractVector).
However:
- The error message 
KeyError: key :name not foundlooks like an internal error that doesn't tell me what the problem is. function(arg) arg + 1 endis actually valid Julia syntax, so one can writemy_func = function(arg) arg + 1 end, much like in R. I guess Turing's models aren't really functions (even though they look exactly like functions), so it's probably fine that some syntax isn't supported, but the error message could use some improvement, IMO
Metadata
Metadata
Assignees
Labels
No labels