Skip to content

Instantly share code, notes, and snippets.

@jrjohansson
Last active August 29, 2015 14:06
Show Gist options
  • Save jrjohansson/123db30ba5defa7a25ad to your computer and use it in GitHub Desktop.
Save jrjohansson/123db30ba5defa7a25ad to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:9414b219fed8ad3639c02dc327c0e68303bd956b04466ce74c609be5ba4cea94"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import qutip"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"q1, q2 = qutip.sigmax(), qutip.sigmay()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"numpy.array([q1, q2])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "a float is required",
"output_type": "pyerr",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-4-3facc10958fd>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnumpy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mq1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mq2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: a float is required"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"numpy.array([q1, q2], dtype=object)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"array([ Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isherm = True\n",
"Qobj data =\n",
"[[ 0. 1.]\n",
" [ 1. 0.]],\n",
" Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isherm = True\n",
"Qobj data =\n",
"[[ 0.+0.j 0.-1.j]\n",
" [ 0.+1.j 0.+0.j]]], dtype=object)"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"type(q1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 6,
"text": [
"qutip.qobj.Qobj"
]
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"class C:\n",
" def __init__(self):\n",
" pass"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"c1, c2 = C(), C()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"numpy.array([c1, c2])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 9,
"text": [
"array([<__main__.C object at 0x10d344320>,\n",
" <__main__.C object at 0x10d344358>], dtype=object)"
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%reload_ext version_information\n",
"\n",
"%version_information numpy, qutip"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>Python</td><td>3.4.1 (default, May 21 2014, 01:39:38) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]</td></tr><tr><td>IPython</td><td>2.1.0</td></tr><tr><td>OS</td><td>posix [darwin]</td></tr><tr><td>numpy</td><td>1.9.0</td></tr><tr><td>qutip</td><td>3.1.0.dev-6504b15</td></tr><tr><td colspan='2'>Thu Sep 11 23:38:58 2014 JST</td></tr></table>"
],
"json": [
"{ \"Software versions\" : [{ \"module\" : \"Python\", \"version\" : \"3.4.1 (default, May 21 2014, 01:39:38) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]\" }, { \"module\" : \"IPython\", \"version\" : \"2.1.0\" }, { \"module\" : \"OS\", \"version\" : \"posix [darwin]\" }, { \"module\" : \"numpy\", \"version\" : \"1.9.0\" }, { \"module\" : \"qutip\", \"version\" : \"3.1.0.dev-6504b15\" } ] }"
],
"latex": [
"\\begin{tabular}{|l|l|}\\hline\n",
"{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n",
"Python & 3.4.1 (default, May 21 2014, 01:39:38) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] \\\\ \\hline\n",
"IPython & 2.1.0 \\\\ \\hline\n",
"OS & posix [darwin] \\\\ \\hline\n",
"numpy & 1.9.0 \\\\ \\hline\n",
"qutip & 3.1.0.dev-6504b15 \\\\ \\hline\n",
"\\hline \\multicolumn{2}{|l|}{Thu Sep 11 23:38:58 2014 JST} \\\\ \\hline\n",
"\\end{tabular}\n"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 10,
"text": [
"Software versions\n",
"Python 3.4.1 (default, May 21 2014, 01:39:38) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]\n",
"IPython 2.1.0\n",
"OS posix [darwin]\n",
"numpy 1.9.0\n",
"qutip 3.1.0.dev-6504b15\n",
"\n",
"Thu Sep 11 23:38:58 2014 JST"
]
}
],
"prompt_number": 10
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment