<jupyter_start><jupyter_text>Animating computations using the hierarchical fiber abstractionThe following cells provide an introduction to the methods provided to animate the activity in a computation.First, we include some libraries and provide some dropdown lists to select the display style and type of animation.<jupyter_code># Run boilerplate code to set up environment

%run ../prelude.py --style=tree --animation=movie<jupyter_output><empty_output><jupyter_text>Animating a computationThe codebase provides some utility functions to animate the accesses to a tensor. The following examples use some convenience functions provided in __prelude.py__ to generate the aninamtions. The behind-the-scenes class used is **TensorCanvas**, which can be used directly.  Create a tensorJust create a tensor to be used in the animation<jupyter_code># Traverse a tensor

a = Tensor.fromYAMLfile(datafileName("matrix-a.yaml"))

displayTensor(a)<jupyter_output><empty_output><jupyter_text>Animate traversal of a tensorThe following cell animates the traversal of a rank-2 tensor. The key methods used are:- **createCanvas(tensor...)** - create a canvas to draw the animation on. The arguments are the tensors that are to be displayed in the animation- **canvas.addFrame(highlight...)** - add a frame to the canvas. The arguments provide the information needed to highlight specific points in each tensor being displayed in this frame. In this example, we just use a the coordinates of a single point as the highlight. See the [tensor highlighting](./highlight-multiPE.ipynb) notebook for details on how to specifiy more complex highlights (Note: addframe does not take a dictionary of PEs to highlight. More sophisticated PE highlighting is accomplished with the **canvas.addActivity()** method)- **displayCanvas(canvas)** - Turn the cavnas into a movie (or spacetime diagram) to be displayed. This convenience functions displays the result in the notebook.<jupyter_code>canvas = createCanvas(a)

a_m = a.getRoot()

for m, (a_k) in a_m:
    print(f"({m}, {a_k})")
    for k, (a_val) in a_k:
        print(f"Processing: ({k}, {a_val})")
        canvas.addFrame((m,k))

displayCanvas(canvas)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07824513794663049, 'fraction_numerical': 0.0004522840343735866, 'mean_word_length': 5.284090909090909, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '429269', 'license': 'MIT', 'n_tokens_mistral': 597, 'n_tokens_neox': 576, 'n_words': 267, 'path': 'notebooks/basic/fibertree-animation.ipynb', 'repo_name': 'FPSG-UIUC/fibertree-notebooks', 'size': '2211'}