Skip to content

Commit 1ea1bea

Browse files
authored
Shorten TraceEvaluation (#1486)
Lines of the form: Replacing: x -> x don't add much, so remove them. In the future, maybe we can have a "verbosity level" to include something like this. The only purpose I can see is to indicate that a rewrite rule was considered and did nothing. However, TraceEvaluations are typically very long and, in my experience, don't add clarity, just clutter.
1 parent 66259ff commit 1ea1bea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mathics/eval/tracing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ def print_evaluate(expr, evaluation, status: str, fn: Callable, orig_expr=None):
122122
expr = expr[0]
123123
elif not evaluation.definitions.trace_evaluation:
124124
return
125-
evaluation.print_out(f"{indents}{status}: {orig_expr} = " + str(expr))
125+
expr_str = str(expr)
126+
if status == "Replacing" and orig_expr == expr_str:
127+
return
128+
evaluation.print_out(f"{indents}{status}: {orig_expr} = {expr_str}")
126129

127130
elif not is_performing_rewrite(fn):
128131
if not evaluation.definitions.trace_evaluation:

0 commit comments

Comments
 (0)