Skip to content

Commit

Permalink
Address PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bwohlberg committed Nov 8, 2024
1 parent fa567c5 commit cddf9b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
17 changes: 9 additions & 8 deletions examples/scripts/trace_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
"""
Initialize tracing. JIT must be disabled for correct tracing.
The call tracing mechanism prints the name, arguments, and return
values of functions/methods as they are called. Module and class
names are printed in light red, function and method names in dark
red, arguments and return values in light blue, and the names of
registered variables in light yellow. When a method defined in a
class is called for an object of a derived class type, the class
of that object is printed in light magenta, in square brackets.
The call tracing mechanism prints the name, arguments, and return values
of functions/methods as they are called. Module and class names are
printed in light red, function and method names in dark red, arguments
and return values in light blue, and the names of registered variables
in light yellow. When a method defined in a class is called for an object
of a derived class type, the class of that object is printed in light
magenta, in square brackets. Function names and return values are
distinguished by initial ">>" and "<<" characters respectively.
"""
jax.config.update("jax_disable_jit", True)
trace_scico_calls()
Expand Down Expand Up @@ -79,7 +80,7 @@ class is called for an object of a derived class type, the class
g_list = [lmbda * functional.L1Norm(), functional.NonNegativeIndicator()]
C_list = [linop.Identity((n)), linop.Identity((n))]
rho_list = [1.0, 1.0]
maxiter = 10 # number of ADMM iterations
maxiter = 1 # number of ADMM iterations (set to small value to simplify trace output)

register_variable(f, "f")
register_variable(g_list[0], "g_list[0]")
Expand Down
7 changes: 5 additions & 2 deletions scico/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
When a method defined in a class is called for an object of a derived
class type, the class of that object is displayed in light magenta, in
square brackets.
square brackets. Function names and return values are distinguished by
initial ``>>`` and ``<<`` characters respectively.
A usage example is provided in the script :code:`trace_example.py`.
"""


Expand Down Expand Up @@ -232,7 +235,7 @@ def wrapper(*args, **kwargs):
# print representation of return value
if ret is not None and call_trace.show_return_value:
print(
f"{clr_main}>> {' ' * 2 * call_trace.trace_level}{clr_retv}"
f"{clr_main}<< {' ' * 2 * call_trace.trace_level}{clr_retv}"
f"{_trace_arg_repr(ret)}{clr_reset}",
file=sys.stderr,
)
Expand Down

0 comments on commit cddf9b4

Please sign in to comment.