|
37 | 37 | def str_for_dist(
|
38 | 38 | dist: TensorVariable, formatting: str = "plain", include_params: bool = True
|
39 | 39 | ) -> str:
|
40 |
| - """Make a human-readable string representation of a Distribution in a model. |
41 |
| -
|
42 |
| - This can be either LaTeX or plain, optionally with distribution parameter |
43 |
| - values included. |
44 |
| - """ |
| 40 | + """Make a human-readable string representation of a Distribution in a model, either LaTeX or plain, optionally with distribution parameter values included.""" |
45 | 41 | if include_params:
|
46 | 42 | if isinstance(dist.owner.op, RandomVariable) or getattr(
|
47 | 43 | dist.owner.op, "extended_signature", None
|
@@ -100,10 +96,8 @@ def str_for_dist(
|
100 | 96 |
|
101 | 97 |
|
102 | 98 | def str_for_model(model: Model, formatting: str = "plain", include_params: bool = True) -> str:
|
103 |
| - """Make a human-readable string representation of Model. |
104 |
| -
|
105 |
| - This lists all random variables and their distributions, optionally |
106 |
| - including parameter values. |
| 99 | + """Make a human-readable string representation of Model, listing all random variables |
| 100 | + and their distributions, optionally including parameter values. |
107 | 101 | """
|
108 | 102 | # Wrap functions to avoid confusing typecheckers
|
109 | 103 | sfd = partial(str_for_dist, formatting=formatting, include_params=include_params)
|
@@ -150,10 +144,8 @@ def str_for_potential_or_deterministic(
|
150 | 144 | include_params: bool = True,
|
151 | 145 | dist_name: str = "Deterministic",
|
152 | 146 | ) -> str:
|
153 |
| - """Make a human-readable string representation of a Deterministic or Potential in a model. |
154 |
| -
|
155 |
| - This can be either LaTeX or plain, optionally with distribution parameter |
156 |
| - values included. |
| 147 | + """Make a human-readable string representation of a Deterministic or Potential in a model, either |
| 148 | + LaTeX or plain, optionally with distribution parameter values included. |
157 | 149 | """
|
158 | 150 | print_name = var.name if var.name is not None else "<unnamed>"
|
159 | 151 | if "latex" in formatting:
|
@@ -309,5 +301,7 @@ def _default_repr_pretty(obj: TensorVariable | Model, p, cycle):
|
309 | 301 |
|
310 | 302 |
|
311 | 303 | def _format_underscore(variable: str) -> str:
|
312 |
| - """Escapes all unescaped underscores in the variable name for LaTeX representation.""" |
| 304 | + """ |
| 305 | + Escapes all unescaped underscores in the variable name for LaTeX representation. |
| 306 | + """ |
313 | 307 | return re.sub(r"(?<!\\)_", r"\\_", variable)
|
0 commit comments