Does PyMC have anything like Turing.jl’s @submodel
macro? I want to compose several Python models together, so that I can keep different parts of my model separate while I work on them and make my code more readable. Thanks!
You can create submodels inside models:
with pm.Model() as m:
with pm.Model() as sub_m1:
...
with pm.Model() as sub_m2:
...
All the variables in sub_m*
will be added to m
. Does that achieve what you wanted?
Partly, but is there a way to define the submodels separately, then call them from inside the main model? (Like functions?)
You could implement an extend_model
function, which would update the parent model attributes with the new variables.
These are the things you need to populate:
You can add new items to treedict
s (just a subclass of dict) and append new values to treelist
s (just a subclass of lists)