Skip to content

Commit 7f6bc9a

Browse files
committed
small refactor
1 parent dd399e9 commit 7f6bc9a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pymc3/printing.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,18 @@ def _str_for_input_var(var: Variable, formatting: str) -> str:
122122
# use the standard functools.singledispatch
123123
if isinstance(var, TensorConstant):
124124
return _str_for_constant(var, formatting)
125-
elif isinstance(var.owner.op, RandomVariable):
125+
elif isinstance(var.owner.op, RandomVariable) or (
126+
hasattr(var, "str_repr")
127+
and (
128+
var.str_repr.__func__ is str_for_deterministic
129+
or var.str_repr.__func__ is str_for_potential
130+
)
131+
):
132+
# show the names for RandomVariables, Deterministics, and Potentials, rather
133+
# than the full expression
126134
return _str_for_input_rv(var, formatting)
127135
elif isinstance(var.owner.op, DimShuffle):
128136
return _str_for_input_var(var.owner.inputs[0], formatting)
129-
elif hasattr(var, "str_repr") and (
130-
var.str_repr.__func__ is str_for_deterministic or var.str_repr.__func__ is str_for_potential
131-
):
132-
# display the name for a Deterministic or Potential, rather than the full expression
133-
return var.name
134137
else:
135138
return _str_for_expression(var, formatting)
136139

0 commit comments

Comments
 (0)