recurse

A class that provides a decorator for visualizing recursion trees and caching results

source

make_args_hashable

 make_args_hashable (args)

source

RecursionVisualizer

 RecursionVisualizer (verbose:bool=False, animate:bool=True,
                      save:bool=False, path:str='',
                      display_args:Union[bool,List]=True)

A class that provides a decorator for visualizing recursion trees and caching results.

Type Default Details
verbose bool False if true, print all nodes
animate bool True if true, create an animation of the recursion tree
save bool False if true, save the animation to a html file
path str path to save the animation to
display_args Union True If True, display all arguments of the recursive function in each node; if list, only display arguments whose indices are in this list

source

on_colab

 on_colab ()

Returns true if code is being executed on Colab, false otherwise

on_colab()
False
@RecursionVisualizer()
def fib(n):
  if n <= 2: 
    return 1
  return fib(n-1) + fib(n-2)
fig, result = fib(5)
result
5