{ "cells": [ { "cell_type": "markdown", "id": "3f7f66b6", "metadata": {}, "source": [ "# Import Tiger and Misc" ] }, { "cell_type": "code", "execution_count": 1, "id": "9cb3bce5", "metadata": {}, "outputs": [], "source": [ "import tc" ] }, { "cell_type": "code", "execution_count": 2, "id": "be38c5fe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tc.has(\"misc\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "9fe09a20", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import tiger_misc\n", "tiger_misc == tc.misc" ] }, { "cell_type": "markdown", "id": "3b3a7285", "metadata": {}, "source": [ "# Misc Library" ] }, { "cell_type": "code", "execution_count": 4, "id": "2be2f25d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['error', 'file_library', 'symbol', 'symbol_fresh', 'timer']" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(filter(lambda e: not e.startswith(\"_\"), dir(tc.misc)))" ] }, { "cell_type": "markdown", "id": "c2ffa10b", "metadata": {}, "source": [ "# Misc error" ] }, { "cell_type": "code", "execution_count": 5, "id": "0ee4cd72", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 SUCCESS\n", "1 FAILURE\n", "2 SCAN\n", "3 PARSE\n", "4 BIND\n", "5 TYPE\n" ] } ], "source": [ "errors_messages = tc.misc.error.error_type_message()\n", "for i in range(6):\n", " print(i, errors_messages[i])" ] }, { "cell_type": "code", "execution_count": 6, "id": "bf7ee0ae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n", "2\n", "3\n", "4\n", "5\n" ] } ], "source": [ "print(tc.misc.error.error_type_success)\n", "print(tc.misc.error.error_type_failure)\n", "print(tc.misc.error.error_type_scan)\n", "print(tc.misc.error.error_type_parse)\n", "print(tc.misc.error.error_type_bind)\n", "print(tc.misc.error.error_type_type)" ] }, { "cell_type": "markdown", "id": "aa79fa38", "metadata": {}, "source": [ "# Misc symbol" ] }, { "cell_type": "code", "execution_count": 7, "id": "082ad376", "metadata": {}, "outputs": [], "source": [ "hello = tc.misc.symbol(\"Hello\")" ] }, { "cell_type": "code", "execution_count": 8, "id": "88a477ec", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "print(type(hello))" ] }, { "cell_type": "code", "execution_count": 9, "id": "315f56d1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Hello'" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(hello)" ] }, { "cell_type": "code", "execution_count": 10, "id": "9614378d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hello == \"Hello\"" ] }, { "cell_type": "code", "execution_count": 11, "id": "14621e65", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hello == tc.misc.symbol(\"Hello\")" ] }, { "cell_type": "code", "execution_count": 12, "id": "dccec330", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hello != tc.misc.symbol(\"world\")" ] }, { "cell_type": "markdown", "id": "a8236c03", "metadata": {}, "source": [ "# Misc timer" ] }, { "cell_type": "code", "execution_count": 13, "id": "2f35c4c7", "metadata": {}, "outputs": [], "source": [ "my_timer = tc.misc.timer()" ] }, { "cell_type": "code", "execution_count": 14, "id": "70f7b6e0", "metadata": {}, "outputs": [], "source": [ "my_timer.start()" ] }, { "cell_type": "code", "execution_count": 15, "id": "8510ce33", "metadata": {}, "outputs": [], "source": [ "my_timer.push('test')" ] }, { "cell_type": "code", "execution_count": 16, "id": "8eeb355b", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Execution times (seconds)\n", "\n", "Cumulated times (seconds)\n", " test : -0.79 ( -79%) -0.13 ( -13%) -1.43526e+07 (-1.44e+09%) \n", "\n", " TOTAL (seconds) : 0 user, 0 system, 0 wall\n" ] } ], "source": [ "#DONTCHECK\n", "my_timer.dump()" ] } ], "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.10.2" } }, "nbformat": 4, "nbformat_minor": 5 }