Investigate namespace issue
Last night, @cameronfreer stumbled across a bug in the tutorial notebook:
(define [_ mh-tr _]
(infer :procedure single-site-metropolis-hastings-step
:inputs [circus-brothers [] initial-trace constraint-addresses]))
=> CompilerException java.lang.AssertionError: Assert failed: ["no such variable" #namespace[metaprob.examples.gaussian] active-ctx?] (var? v)
implying that Metaprob was trying (and failing) to resolve active-ctx? in the metaprob.examples.gaussian namespace. That active-ctx? is defined in context.clj, so adding
[metaprob.context :refer :all]
to the requires at the top of examples.gaussian file addressed the immediate problem. However, this implies there's something unexpected going on. As @alex-lew said in Slack:
Yeah. The
gens created bymake-inference-procedure-from-sampler-and-scorershould not be namespaced togaussian, even if it's called from there
Investigate why this happened. If it's what we expected we should document why it didn't match our initial expectations, and if it's a bug then fix it :)
This could once again be legacy of python-metaprob compatibility. When I originally did the port I baked in the assumption that metaprob was not namespaced (i.e. it was intended that all metaprob code live in the same clojure namespace). Then it got namespaced partway via the *ns* hack. I'm sorry I don't remember the details but you may need to review the way symbols are handled in the meta-circular interpreter and in the macro expanders for block and friends. It would be unfortunate if the meta-circular interpreter had to know about clojure namespace but it's possible it will have to.