Closed
Description
Before
# Currently would have to create graphviz instance
graph = pm.model_to_graphviz(model)
# Save output to .dot file and manually modify subgraph labels
print(graph)
# Resave as pdf using dot cli
After
# Might be similar to that of where the entry point to the change would be in `pm.model_to_graphviz`
def named_vars_plate_label(
var: TensorVariable,
named_vars_to_dims: dict[str, Sequence[str]],
dim_lengths: dict[str, int],
) -> str:
dims = named_vars_to_dims[var.name]
return " x ".join(str(dim) for dim in dims)
plate_formatters = {
"Named Vars": named_vars_plate_label,
}
pm.model_to_graphviz(model, plate_formatters=plate_formatters)
Context for the issue:
I am interested in making graphviz diagraphs with a bit more customization of the plate labels than currently supported. Specifically, I would like to allow for labels without the shape size to provide a more abstract representation of the model. My specific example might look like this:
I am willing to take up this issue. Wondering if there are any preferences on the implementation details? My idea would involve extracting this logic here and providing some logic based on:
- var : TensorVariable
- named_vars_to_dims : var.name mapping to coord names
- dim_lengths : coord names mapping to either TensorVariable or pre-evaluated shapes (addressing this TODO)
Related to #6716