Improve support of nested models #5341
Replies: 5 comments 6 replies
-
Is there a case not to share dims by default? |
Beta Was this translation helpful? Give feedback.
-
I just opened #5344 that should handle the nested model dims and coords. What should we do about the name prefix? I think the best thing to do would be to always add the parent model name as a prefix for the nested model's name. |
Beta Was this translation helpful? Give feedback.
-
What do you think of / as scope separator? |
Beta Was this translation helpful? Give feedback.
-
I was aware about limitations and had plans to improve it |
Beta Was this translation helpful? Give feedback.
-
@ricardoV94 slash does not seem to break anything. PyMC+Xarray+Arviz |
Beta Was this translation helpful? Give feedback.
-
At the moment,
pymc.Model
instances serve two purposes:The book keeping functionality enables nice features out of the box, like being able to draw the probabilistic graph of only a subset of random variables with graphviz:
renders the following graphs:
The main problem is that the child model does not inherit its parents coords. Note that this snippet leads to an error because
m2
does not define the "dim" dimension:One other problem is that the nested model's name completely supresses the parent model's name. Note that
d.name
is "m2_d" and not "m1_m2_d", which is more consistent in my opinion.I've opened this discussion to ask if there's any interest in having nested models inherit their parent's coordinates, and whether their name should also include their parent's name, if any.
The first point is fairly straightforward to implement. We only need to copy the pattern that is used in the
free_RVs
, etc, attributes as done here and apply it also to the model's_coords
,_RV_dims
and_dim_lengths
attributes.The point about the model name should be even simpler to implement.
Beta Was this translation helpful? Give feedback.
All reactions