pymc-devs / pymc-devs/nutpie

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

Open
#136 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
207
Forks
28
Avg merge
7d 21h
Merged PRs (30d)
1

Description

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'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided PyMC and nutpie example, then inspect the compiled model's with_data entry point and shared-variable name handling. Done means updating n with compiled.with_data(n=15) works for a model named "a good name" without the reported KeyError, while the existing prefixed form remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.