{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Details on the file_formats module" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**For a description on how to use the most important functionality, please checkout the tutorials and the API documentation.**\n", "\n", "The following example code shows how to use most of the functionality of the `tempo.file_formats` module. This code is *suplementary* to the documentation and also includes functionality that is only relevant to the inner workings of the TimeEvolvingMPO package. Sections that show example code that is not part of the API is marked with three asterix `***`.\n", "\n", "**Contents:**\n", "\n", "* A: Check file.tempoDynamics\n", " * A1: Check file.tempoDynamics\n", " * A2: Print file.tempoDynamics\n", "* B: File format .processTensor \n", " * B1: Check file.processTensor\n", " * B2: Print file.processTensor\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.insert(0,'..')\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "import time_evolving_mpo as tempo" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A: File format .tempoDynamics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### A1: Check file.tempoDynamics" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# tempo.file_formats.assert_tempo_dynamics_file(\"../tests/data/test_v1_0_good_file_C.tempoDynamics\") \n", "tempo.file_formats.check_tempo_dynamics_file(\"../tests/data/test_v1_0_good_file_C.tempoDynamics\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# tempo.file_formats.assert_tempo_dynamics_file(\"../tests/data/test_v1_0_bad_file_A.tempoDynamics\")\n", "tempo.file_formats.check_tempo_dynamics_file(\"../tests/data/test_v1_0_bad_file_A.tempoDynamics\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### A2: Print file.tempoDynamics" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tempo Dynamics:\n", " version = 1.0\n", " name = Ralph\n", " description = wonderful\n", " description_dict = dict:\n", " alpha : 0.3\n", " omega : 4.0\n", " times = steps:4, min:0.0, max:0.4\n", " states = shape:(4, 5, 5)\n" ] } ], "source": [ "tempo.file_formats.print_tempo_dynamics_file(\"../tests/data/test_v1_0_good_file_C.tempoDynamics\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## B: File format .processTensor " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### B1: Check file.processTensor" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# tempo.file_formats.assert_process_tensor_file(\"../tests/data/test_v1_0_good_file_C.processTensor\") \n", "tempo.file_formats.check_process_tensor_file(\"../tests/data/test_v1_0_good_file_C.processTensor\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# tempo.file_formats.assert_process_tensor_file(\"../tests/data/test_v1_0_bad_file_A.processTensor\")\n", "tempo.file_formats.check_process_tensor_file(\"../tests/data/test_v1_0_bad_file_A.processTensor\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### B2: Print file.processTensor" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Process Tensor:\n", " version = 1.0\n", " name = Eve\n", " description = The initial state\n", " description_dict = dict:\n", " alpha : 0.3\n", " epsilon : 3.3e-07\n" ] } ], "source": [ "tempo.file_formats.print_process_tensor_file(\"../tests/data/test_v1_0_good_file_D.processTensor\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Process Tensor:\n", " version = 1.0\n", " name = temp\n", " description = - \n", " description_dict = dict:\n" ] } ], "source": [ "tempo.file_formats.print_process_tensor_file(\"/data/git/tempo_py/example.processTensor\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }