mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-07 13:07:22 +08:00
Minor changes to nb examples
This commit is contained in:
parent
96d40d6136
commit
08572034b5
@ -1,7 +1,8 @@
|
||||
{
|
||||
"metadata": {
|
||||
"gist_id": "6011986",
|
||||
"name": ""
|
||||
"name": "",
|
||||
"signature": "sha256:26d4e13b833b84557da8501e68fc5119f11a3c1cdbecba63c0ab613e0cb0619f"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
@ -260,7 +261,7 @@
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"ls nbimp"
|
||||
"ls nbpackage"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
@ -269,7 +270,7 @@
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"__init__.py __init__.pyc bs.ipynb mynotebook.ipynb \u001b[34mnbs\u001b[m\u001b[m/\r\n"
|
||||
"__init__.py mynotebook.ipynb \u001b[34mnbs\u001b[m\u001b[m/\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -392,7 +393,7 @@
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"text": [
|
||||
"<IPython.core.display.HTML at 0x10a006890>"
|
||||
"<IPython.core.display.HTML at 0x1072303d0>"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -415,7 +416,7 @@
|
||||
" html.append(\"<pre>%s</pre>\" % cell.source)\n",
|
||||
" display(HTML('\\n'.join(html)))\n",
|
||||
"\n",
|
||||
"show_notebook(os.path.join(\"nbimp\", \"mynotebook.ipynb\"))"
|
||||
"show_notebook(os.path.join(\"nbpackage\", \"mynotebook.ipynb\"))"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
@ -443,11 +444,11 @@
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"text": [
|
||||
"<IPython.core.display.HTML at 0x10ad7af10>"
|
||||
"<IPython.core.display.HTML at 0x10775a150>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 9
|
||||
"prompt_number": 10
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@ -463,7 +464,7 @@
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"from nbimp import mynotebook"
|
||||
"from nbpackage import mynotebook"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
@ -472,11 +473,11 @@
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"importing IPython notebook from nbimp/mynotebook.ipynb\n"
|
||||
"importing IPython notebook from nbpackage/mynotebook.ipynb\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 10
|
||||
"prompt_number": 11
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@ -497,13 +498,13 @@
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 11,
|
||||
"prompt_number": 12,
|
||||
"text": [
|
||||
"'foo'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 11
|
||||
"prompt_number": 12
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@ -526,39 +527,20 @@
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 12,
|
||||
"prompt_number": 13,
|
||||
"text": [
|
||||
"['Animations Using clear_output.ipynb',\n",
|
||||
" 'Cell Magics.ipynb',\n",
|
||||
" 'Custom Display Logic.ipynb',\n",
|
||||
" 'Cython Magics.ipynb',\n",
|
||||
" 'Data Publication API.ipynb',\n",
|
||||
" 'Frontend-Kernel Model.ipynb',\n",
|
||||
" 'Connecting with the Qt Console.ipynb',\n",
|
||||
" 'Importing Notebooks.ipynb',\n",
|
||||
" 'Octave Magic.ipynb',\n",
|
||||
" 'Part 1 - Running Code.ipynb',\n",
|
||||
" 'Part 2 - Basic Output.ipynb',\n",
|
||||
" 'Part 3 - Plotting with Matplotlib.ipynb',\n",
|
||||
" 'Part 4 - Markdown Cells.ipynb',\n",
|
||||
" 'Part 5 - Rich Display System.ipynb',\n",
|
||||
" 'Progress Bars.ipynb',\n",
|
||||
" 'R Magics.ipynb',\n",
|
||||
" 'README.md',\n",
|
||||
" 'Script Magics.ipynb',\n",
|
||||
" 'SymPy Examples.ipynb',\n",
|
||||
" 'Raw Input.ipynb',\n",
|
||||
" 'SymPy.ipynb',\n",
|
||||
" 'Trapezoid Rule.ipynb',\n",
|
||||
" 'Typesetting Math Using MathJax.ipynb',\n",
|
||||
" 'animation.m4v',\n",
|
||||
" 'foo.pyx',\n",
|
||||
" 'lnum.py',\n",
|
||||
" 'logo',\n",
|
||||
" 'nbimp',\n",
|
||||
" 'python-logo.svg',\n",
|
||||
" 'test.html']"
|
||||
" 'nbpackage']"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 12
|
||||
"prompt_number": 13
|
||||
},
|
||||
{
|
||||
"cell_type": "heading",
|
||||
@ -580,7 +562,7 @@
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"ls nbimp/nbs"
|
||||
"ls nbpackage/nbs"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
@ -589,11 +571,11 @@
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"__init__.py __init__.pyc other.ipynb\r\n"
|
||||
"__init__.py other.ipynb\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 13
|
||||
"prompt_number": 14
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@ -607,7 +589,7 @@
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"show_notebook(os.path.join(\"nbimp\", \"nbs\", \"other.ipynb\"))"
|
||||
"show_notebook(os.path.join(\"nbpackage\", \"nbs\", \"other.ipynb\"))"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
@ -624,17 +606,17 @@
|
||||
"metadata": {},
|
||||
"output_type": "display_data",
|
||||
"text": [
|
||||
"<IPython.core.display.HTML at 0x10ad56090>"
|
||||
"<IPython.core.display.HTML at 0x10775a250>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 14
|
||||
"prompt_number": 15
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"from nbimp.nbs import other\n",
|
||||
"from nbpackage.nbs import other\n",
|
||||
"other.bar(5)"
|
||||
],
|
||||
"language": "python",
|
||||
@ -644,19 +626,19 @@
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"importing IPython notebook from nbimp/nbs/other.ipynb\n"
|
||||
"importing IPython notebook from nbpackage/nbs/other.ipynb\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 15,
|
||||
"prompt_number": 16,
|
||||
"text": [
|
||||
"'barbarbarbarbar'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 15
|
||||
"prompt_number": 16
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@ -675,14 +657,14 @@
|
||||
"from IPython.utils.path import get_ipython_package_dir\n",
|
||||
"\n",
|
||||
"utils = os.path.join(get_ipython_package_dir(), 'utils')\n",
|
||||
"shutil.copy(os.path.join(\"nbimp\", \"mynotebook.ipynb\"),\n",
|
||||
"shutil.copy(os.path.join(\"nbpackage\", \"mynotebook.ipynb\"),\n",
|
||||
" os.path.join(utils, \"inside_ipython.ipynb\")\n",
|
||||
")"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 16
|
||||
"prompt_number": 17
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@ -705,83 +687,26 @@
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"importing IPython notebook from /Users/minrk/dev/ip/mine/IPython/utils/inside_ipython.ipynb\n"
|
||||
"importing IPython notebook from /Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/inside_ipython.ipynb\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 17,
|
||||
"prompt_number": 18,
|
||||
"text": [
|
||||
"'IPython.utils.inside_ipython'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 17
|
||||
},
|
||||
{
|
||||
"cell_type": "heading",
|
||||
"level": 2,
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Even Cython magics"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"With a bit of extra magic for handling the IPython interactive namespace during load,\n",
|
||||
"even magics like `%%cython` can be used:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"import Cython_Magics"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"importing IPython notebook from Cython Magics.ipynb\n",
|
||||
"1000000 loops, best of 3: 439 ns per loop"
|
||||
]
|
||||
},
|
||||
{
|
||||
"output_type": "stream",
|
||||
"stream": "stdout",
|
||||
"text": [
|
||||
"\n",
|
||||
"sin(1)= 0.841470984808\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 18
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"Cython_Magics.black_scholes(100.0, 100.0, 1.0, 0.3, 0.03, 0.0, -1)"
|
||||
],
|
||||
"language": "python",
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 19,
|
||||
"text": [
|
||||
"10.327861752731728"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 19
|
||||
"source": [
|
||||
"This approach can even import functions and classes that are defined in a notebook using the `%%cython` magic."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
|
Loading…
Reference in New Issue
Block a user