Skip to content

Commit

Permalink
Run qip notebook with qutip 4.6 (qutip#125)
Browse files Browse the repository at this point in the history
* Run notebook with qutip 4.6

* Update examples/teleportation.ipynb

Co-authored-by: Nathan Shammah <nathan.shammah@gmail.com>

* minor changes, align the points

Co-authored-by: Nathan Shammah <nathan.shammah@gmail.com>
  • Loading branch information
BoxiLi and nathanshammah authored May 25, 2021
1 parent 4268606 commit 163ede3
Show file tree
Hide file tree
Showing 6 changed files with 422 additions and 728 deletions.
101 changes: 29 additions & 72 deletions examples/qasm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Qasm - Imports and Exports\n",
"# Imports and Exports QASM circuit\n",
"\n",
"Notebook Author: Sidhant Saraogi(sid1397@gmail.com)"
]
Expand Down Expand Up @@ -238,23 +238,18 @@
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Quantum object: dims = [[2, 2], [1, 1]], shape = (4, 1), type = ket\n",
"Qobj data =\n",
"[[0.]\n",
" [0.]\n",
" [1.]\n",
" [0.]]\n",
"1.0\n"
]
},
{
"data": {
"text/latex": [
"Quantum object: dims = [[2, 2], [1, 1]], shape = (4, 1), type = ket\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0\\\\0.0\\\\1.0\\\\0.0\\\\\\end{array}\\right)\\end{equation*}"
],
"text/plain": [
"<qutip.qip.circuit.Result at 0x102261590>"
"Quantum object: dims = [[2, 2], [1, 1]], shape = (4, 1), type = ket\n",
"Qobj data =\n",
"[[0.]\n",
" [0.]\n",
" [1.]\n",
" [0.]]"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -338,7 +333,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/sid/Documents/qutip_dev/qutip/qutip/qip/qasm.py:684: UserWarning: Information about individual registers is not preserved in QubitCircuit\n",
"e:\\boxi\\onedrive\\studium\\qutip-project\\qutip\\qutip\\qip\\qasm.py:684: UserWarning: Information about individual registers is not preserved in QubitCircuit\n",
" warnings.warn((\"Information about individual registers\"\n"
]
}
Expand All @@ -364,34 +359,16 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = (8, 1), type = ket\n",
"Qobj data =\n",
"[[ 0. +0.j ]\n",
" [ 0. +0.j ]\n",
" [-0.47169938+0.23335464j]\n",
" [ 0.72621697-0.44232818j]\n",
" [ 0. +0.j ]\n",
" [ 0. +0.j ]\n",
" [ 0. +0.j ]\n",
" [ 0. +0.j ]]\n",
"0.2499999999999999\n"
]
}
],
"outputs": [],
"source": [
"state = tensor(rand_ket(2), basis(2, 0), basis(2, 0))\n",
"\n",
"initial_measurement = Measurement(\"start\", targets=[0])\n",
"_, initial_probabilities = initial_measurement.measurement_comp_basis(state)\n",
"\n",
"state_final, probability = teleportation.run(state).get_results(0)\n",
"state_final = teleportation.run(state)\n",
"\n",
"final_measurement = Measurement(\"start\", targets=[2])\n",
"_, final_probabilities = final_measurement.measurement_comp_basis(state_final)\n",
Expand All @@ -409,46 +386,26 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"QuTiP: Quantum Toolbox in Python\n",
"================================\n",
"Copyright (c) QuTiP team 2011 and later.\n",
"Original developers: R. J. Johansson & P. D. Nation.\n",
"Previous lead developers: Chris Granade & A. Grimsmo.\n",
"Current admin team: Alexander Pitchford, Paul D. Nation, Nathan Shammah, Shahnawaz Ahmed, Neill Lambert, Eric Giguère, and Boxi Li\n",
"Project Manager: Franco Nori.\n",
"Currently developed through wide collaboration. See https://github.com/qutip for details.\n",
"\n",
"QuTiP Version: 4.6.0.dev0+ca5c4e4c\n",
"Numpy Version: 1.19.0\n",
"Scipy Version: 1.5.1\n",
"Cython Version: 0.29.13\n",
"Matplotlib Version: 3.3.0\n",
"Python Version: 3.7.4\n",
"Number of CPUs: 2\n",
"BLAS Info: OPENBLAS\n",
"OPENMP Installed: False\n",
"INTEL MKL Ext: False\n",
"Platform Info: Darwin (x86_64)\n",
"Installation path: /Users/sid/Documents/qutip_dev/qutip/qutip\n",
"==============================================================================\n",
"Please cite QuTiP in your publication.\n",
"==============================================================================\n",
"For your convenience a bibtex reference can be easily generated using `qutip.cite()`\n"
]
"data": {
"text/html": [
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>QuTiP</td><td>4.6.0+c003ff5</td></tr><tr><td>Numpy</td><td>1.20.1</td></tr><tr><td>SciPy</td><td>1.5.3</td></tr><tr><td>matplotlib</td><td>3.3.0</td></tr><tr><td>Cython</td><td>0.29.21</td></tr><tr><td>Number of CPUs</td><td>12</td></tr><tr><td>BLAS Info</td><td>Generic</td></tr><tr><td>IPython</td><td>7.16.1</td></tr><tr><td>Python</td><td>3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 18:22:52) [MSC v.1916 64 bit (AMD64)]</td></tr><tr><td>OS</td><td>nt [win32]</td></tr><tr><td colspan='2'>Mon Apr 12 19:27:45 2021 W. Europe Daylight Time</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import qutip\n",
"\n",
"qutip.about()"
"from qutip.ipynbtools import version_table\n",
"version_table()"
]
}
],
Expand All @@ -468,7 +425,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.8.6"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 163ede3

Please sign in to comment.