{ "cells": [ { "cell_type": "markdown", "id": "23f6d43f-dd17-4020-971e-5bb8a5b1e30b", "metadata": {}, "source": [ "# test: locals_jupyter()\n", "Show a graph build with the filtered Jupyter locals using function `memory_graph.locals_jupyter()`. Just adding integers to a list:" ] }, { "cell_type": "code", "execution_count": null, "id": "e8913787-bbef-4adb-b027-ac0f28500233", "metadata": {}, "outputs": [], "source": [ "import memory_graph\n", "\n", "data = []\n", "for i in range(20):\n", " data.append(i)\n", " memory_graph.show(memory_graph.locals_jupyter(), block=True)" ] }, { "cell_type": "markdown", "id": "f66d9b8d-0937-4ad0-97b4-a7459e84c4f2", "metadata": {}, "source": [ "# test: get_call_stack_jupyter()\n", "Show a graph build the filterd Jupyter call stack from function `memory_graph.get_call_stack_jupyter()`. Recursively filling a list with all permutation of elements with resampling:" ] }, { "cell_type": "code", "execution_count": null, "id": "15d0c443-7cc6-4b4f-a9db-598aaf261364", "metadata": {}, "outputs": [], "source": [ "import memory_graph\n", "\n", "def get_all_permutations(permutations, elements, data, max_length):\n", " if len(data) == max_length: # recursive stop condition\n", " permutations.append(data.copy())\n", " else:\n", " for i in elements:\n", " data.append(i)\n", " memory_graph.show(memory_graph.get_call_stack_jupyter() ,block=True)\n", " get_all_permutations(permutations, elements, data, max_length)\n", " data.pop()\n", " memory_graph.show(memory_graph.get_call_stack_jupyter(), block=True)\n", "\n", "permutations = []\n", "get_all_permutations(permutations, ['L','R'], [], 3)\n", "print(permutations)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.0rc1" } }, "nbformat": 4, "nbformat_minor": 5 }