Skip to content

Commit f58491a

Browse files
committed
Add a table method to Model
1 parent e9cf20d commit f58491a

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

pymc/model/core.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,26 @@ def to_graphviz(
20362036
dpi=dpi,
20372037
)
20382038

2039+
def table(
2040+
self,
2041+
*,
2042+
split_groups: bool = True,
2043+
truncate_deterministic: int | None = None,
2044+
parameter_count: bool = True,
2045+
):
2046+
"""Create a rich table summarizing the model's variables and their expressions.
2047+
2048+
See :func:`pymc.model_table` for details.
2049+
"""
2050+
from pymc.printing import model_table
2051+
2052+
return model_table(
2053+
self,
2054+
split_groups=split_groups,
2055+
truncate_deterministic=truncate_deterministic,
2056+
parameter_count=parameter_count,
2057+
)
2058+
20392059

20402060
class BlockModelAccess(Model):
20412061
"""Can be used to prevent user access to Model contexts."""

pymc/printing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def _extract_dim_value(var: Variable) -> np.ndarray:
420420
return " × ".join(f"{dim}[{dim_size}]" for dim, dim_size in dim_sizes.items())
421421
if not isinstance(var.type, HasShape):
422422
return ""
423-
shape_values = list(pt.as_tensor(var.shape).eval(mode=_cheap_eval_mode))
423+
shape_values = list(pt.as_tensor(var.shape).eval(mode=_cheap_eval_mode)) # type: ignore[attr-defined]
424424
return f"[{', '.join(map(str, shape_values))}]" if shape_values else ""
425425

426426

0 commit comments

Comments
 (0)