nutpie icon indicating copy to clipboard operation
nutpie copied to clipboard

`with_data` doesn't recognize shared variables when the compiled model has a name

Open a2435191 opened this issue 1 year ago • 0 comments

I figured out that you have to prefix the model name followed by two colons when updating variables in the with_data keyword arguments. I don't know if this is intended, but I thought I would raise this issue so that other people can search for it.

import pymc as pm
import nutpie

with pm.Model("a good name") as my_model:
    n = pm.Data("n", 1)
    pm.Binomial("my_var", n=n, p=0.7, observed=n.eval()/2)

compiled = nutpie.compile_pymc_model(model)
compiled.with_data(updates={'a good name::n', 15}) # works
compiled.with_data(n=15) # throws KeyError: 'Unknown shared variable: updates'

a2435191 avatar Jul 10 '24 17:07 a2435191