https://github.com/GPflow/GPflow
Raw File
Tip revision: 9c8818e7c6fd1aa9be306fbfa618b09465edbb5f authored by frgsimpson on 08 August 2022, 09:57:16 UTC
Add random inits
Tip revision: 9c8818e
debugger.py
import inspect

ENABLE = True
SHAPE_ONLY = True


def print_locals(stack_index: int = 1) -> None:
    if not ENABLE:
        return

    stack = inspect.stack()
    frame_info = stack[stack_index]
    frame = frame_info.frame
    print("**************************************************")
    print("Locals of:", frame.f_code.co_name)
    print("**************************************************")

    sentinel = object()
    for name, value in frame.f_locals.items():
        if SHAPE_ONLY:
            shape = getattr(value, "shape", sentinel)
            if shape is not sentinel:
                value = shape
        print(name, value)
back to top