notebook/examples/tests/Test Output Callbacks.ipynb

269 lines
4.7 KiB
Plaintext
Raw Normal View History

{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Basic Output"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.display import display"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-01-07 04:15:18 +08:00
"print('hi')"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"display('hi')"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"1"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"plt.plot([1,3,2])"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%javascript\n",
"console.log(\"I ran!\");"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%html\n",
"<b>bold</b>"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%latex\n",
"$$\n",
"a = 5\n",
"$$"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"input_request"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"raw_input(\"prompt > \")"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"set_next_input"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%writefile tst.py\n",
"def foo():\n",
" pass\n"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%load tst.py"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Pager in execute_reply"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt?"
],
"language": "python",
"metadata": {},
2013-10-03 04:34:39 +08:00
"outputs": []
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"object_info"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-01-07 04:15:18 +08:00
"# press shift-tab after parentheses\n",
"int("
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"complete"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-01-07 04:15:18 +08:00
"# press tab after f\n",
"f"
],
"language": "python",
"metadata": {},
"outputs": []
2013-10-03 04:34:39 +08:00
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"clear_output"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-01-07 04:15:18 +08:00
"import sys, time\n",
2013-10-03 04:34:39 +08:00
"from IPython.display import clear_output"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"for i in range(10):\n",
" clear_output()\n",
" time.sleep(0.25)\n",
2014-01-07 04:15:18 +08:00
" print(i)\n",
2013-10-03 04:34:39 +08:00
" sys.stdout.flush()\n",
" time.sleep(0.25)\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"for i in range(10):\n",
" clear_output(wait=True)\n",
" time.sleep(0.25)\n",
2014-01-07 04:15:18 +08:00
" print(i)\n",
2013-10-03 04:34:39 +08:00
" sys.stdout.flush()\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}