{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true, "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "# Working with the IPython notebook\n", "Gert-Ludwig Ingold \n", "
source: `git clone https://github.com/gertingold/lit2015`
\n", "
static view: http://nbviewer.ipython.org/github/gertingold/lit2015/blob/master/pugmuc2015.ipynb
\n", "
Python and Plone User Group Meeting, Munich, 6/2/2015
" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_type": "subslide" }, "slideshow": { "slide_type": "slide" } }, "source": [ "## From Newton's notebook" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "source": [ "" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "source": [ "### From Newton to a modern notebook\n", "* *explanations* \n", " text which may be structured and contain formulae\n", "* *mathematical manipulations* \n", "code and results\n", "* *diagrams* \n", "graphical representations and multimedia objects\n", "* *representation* \n", "HTML, PDF, …" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "subslide" } }, "source": [ "### Applications of notebooks\n", "* Development of small Python scripts \n", " example: optimization for Cython\n", "* Documentation \n", " example: data analysis\n", "* Teaching material \n", " examples: lectures, programming course\n", "* Textbooks \n", " examples: [nbviewer.ipython.org](http://nbviewer.ipython.org/), books section\n", "* Presentation \n", "with notebook extension RISE by Damián Avila\n", "* …" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "## Python\n", "\n", "* interpreted language\n", "* relatively easy to learn\n", "* \"Python comes with batteries included\"\n", "* SciPy stack: NumPy, SciPy, Matplotlib, pandas,..." ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "## IPython - the improved Python shell\n", "\n", "* 2001: Fernando Pérez launches the IPython project.\n", "* December 2011: IPython 0.12 introduces the **IPython notebook**. \n", "* 2013–2014: The development of IPython is supported by the Alfred P. Sloan foundation with 1.15 M`$`.\n", "* August 2013: Microsoft supports the development of IPython with 100.000`$`.\n", "* February, 27 2015: Release of Version 3.0.\n", "* May 2015: IPython is part of the Horizon 2020 project [OpenDreamKit](http://opendreamkit.org)\n", "* Next milestone: The language agnostic part moves to the [Jupyter project](http://jupyter.org)." ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "### IPython sources\n", "Homepage: [ipython.org](http://ipython.org) \n", "Repository: [github.com/ipython/ipython](http://github.com/ipython/ipython) \n", "Mailing list: ipython-dev@scipy.org\n", "\n", "### Debian and Ubuntu packages:\n", "`ipython-notebook` / `ipython3-notebook` \n", "ipython 1.2.1: Debian wheezy-backports, Ubuntu 14.04LTS \n", "ipython 2.3.0: Debian jessie, Ubuntu 15.04 \n", "ipython 3.1.0: [pypi.python.org](http://pypi.python.org)\n", "\n", "### Installation within a virtual environment\n", "`pip install \"ipython[notebook]\"`\n", "\n", "see also: [ipython.org/install.html](http://ipython.org/install.html)\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "## Notebook cells\n", "\n", "* Code cells\n", "* Text cells\n", "* Raw cells for interpretation by `NBConvert`" ] }, { "cell_type": "markdown", "metadata": { "internals": { "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "source": [ "### Working with notebook cells\n", "\n", "A selected notebook cell is in one of two modes:\n", "\n", "* command mode = black frame\n", "* input mode = green frame and pencil symbol in header\n", "* switch to input mode: `ENTER` or doubleclick\n", "* switch to command mode: `ESC` or `CTRL-M`" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_number": 9, "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "source": [ "### Useful keyboard shortcuts\n", "* `SHIFT-ENTER`, `CTRL-ENTER`: execute the selected cell\n", "* `ALT-ENTER`: execute the selected cell and open a new one\n", "* `A`: insert a new cell above the present cell\n", "* `B`: insert a new cell below the present cell\n", "* `D,D`: delete the selected cell\n", "* `M`: define selected cell as markdown cell\n", "* `H`: display all keyboard shortcuts" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 9, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "### Code cells" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 11 }, "scrolled": true, "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "for n in range(3):\n", " print(\"The IPython notebook is great.\")" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 11 }, "slideshow": { "slide_type": "-" } }, "source": [ "Code cells are numbered in the sequence in which they are executed." ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 14 }, "slideshow": { "slide_type": "fragment" } }, "source": [ "Magics can be used to insert and execute code not written in Python, e.g. HTML:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 14, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "%%html\n", " " ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 14, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "### Text cells" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 14, "slide_helper": "subslide_end" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "source": [ "Formatting can be down in markdown and HTML.\n", "\n", "Examples:\n", "* *text in italics* oder _text in italics_\n", "* **text in bold** oder __text in bold__\n", "* `code`\n", "* emphasized text\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 14, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "### Mathematical typesetting\n", "LaTeX syntax can be used in text cells to display mathematical symbols like $\\ddot x$ or entire formulae:\n", "$$\\mathcal{L}\\{f(t)\\} = \\int_0^\\infty\\text{d}z\\text{e}^{-zt}f(t)$$" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 19 }, "slideshow": { "slide_type": "fragment" } }, "source": [ "\n", "Mathematics is displayed with MathJax ([www.mathjax.org](http://www.mathjax.org))\n", "and requires either an internet connection or a local installation. Instructions for a local installation can be obtained as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 19, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "slide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "from IPython.external import mathjax\n", "mathjax?" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 19, "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "## Selected features of the IPython shell" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 19, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "### Help" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "internals": { "frag_helper": "fragment_end", "frag_number": 23 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "import numpy as np\n", "np.tensordot?" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 24 }, "slideshow": { "slide_type": "fragment" } }, "source": [ "Description including code (if available)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "internals": { "frag_helper": "fragment_end", "frag_number": 24 }, "scrolled": true, "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "np.tensordot??" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 26 }, "slideshow": { "slide_type": "fragment" } }, "source": [ "Code completion with `TAB`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 26, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "np.ALLOW_THREADS" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 26, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "### Reference to earlier results" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 29 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "2**3" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 30 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "_-8" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 31 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "__**2" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 32 }, "slideshow": { "slide_type": "fragment" } }, "source": [ "### Access to all earlier input and output" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 33, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "In, Out" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 33, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "### Magics in IPython" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 33, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "%lsmagic" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 33, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "Quick reference" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 33, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "%quickref" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 33, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "Timing of code execution" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 39 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "%timeit 2.5**100" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "internals": { "frag_helper": "fragment_end", "frag_number": 40 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "import math" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 40 }, "scrolled": true, "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "%%timeit \n", "result = []\n", "nmax = 100000\n", "dx = 0.001\n", "for n in range(nmax):\n", " result.append(math.sin(n*dx))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 42, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "slide_end", "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "%%timeit\n", "nmax = 100000\n", "dx = 0.001\n", "x = np.arange(nmax)*dx\n", "result = np.sin(x)" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 42, "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "slide" } }, "source": [ "## Extended representations" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 42, "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "source": [ "IPython allows for the representation of objects in formats as different as\n", "\n", "* HTML\n", "* Markdown\n", "* SVG\n", "* PNG\n", "* JPEG\n", "* LaTeX" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 42, "slide_type": "subslide" }, "scrolled": true, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "from IPython.display import Image\n", "Image(\"./images/ipython_logo.png\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "from IPython.display import HTML\n", "HTML('')" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "Even the embedding of audio and video files is possible." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "from IPython.display import YouTubeVideo\n", "YouTubeVideo('F4rFuIb1Ie4')" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_type": "subslide" }, "slideshow": { "slide_type": "subslide" } }, "source": [ "Python allows for a textual representation of objects by means of the ``__repr__`` method. \n", "\n", "example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "class MyObject(object):\n", " def __init__(self, obj):\n", " self.obj = obj\n", " \n", " def __repr__(self):\n", " return \">>> {0!r} / {0!s} <<<\".format(self.obj)\n", " \n", "x = MyObject('Python')\n", "print(x)" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_helper": "subslide_end", "slide_type": "subslide" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "source": [ "A rich representation of objects is possible in the IPython notebook provided the corresponding methods are defined:\n", "\n", "* `_repr_pretty_`\n", "* `_repr_html_`\n", "* `_repr_markdown_`\n", "* `_repr_latex`\n", "* `_repr_svg_`\n", "* `_repr_json_`\n", "* `_repr_javascript_`\n", "* `_repr_png_`\n", "* `_repr_jpeg_`\n", "\n", "Note: In contrast to `__repr__` only one underscore is used." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_helper": "subslide_end", "slide_type": "subslide" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "class RGBColor(object):\n", " def __init__(self, r, g, b):\n", " self.colordict = {\"r\": r, \"g\":g, \"b\": b}\n", " \n", " def _repr_svg_(self):\n", " return '''\n", " \n", " '''.format(**self.colordict)\n", "\n", "c = RGBColor(205, 128, 255)\n", "c" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_type": "subslide" }, "scrolled": true, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "from fractions import Fraction\n", "\n", "class MyFraction(Fraction):\n", " def _repr_html_(self):\n", " return \"%s%s\" % (self.numerator,\n", " self.denominator)\n", " \n", " def _repr_latex_(self):\n", " return r\"$\\frac{%s}{%s}$\" % (self.numerator, self.denominator)\n", " \n", " def __add__(a, b):\n", " \"\"\"a + b\"\"\"\n", " return MyFraction(a.numerator * b.denominator +\n", " b.numerator * a.denominator,\n", " a.denominator * b.denominator)\n", " \n", "MyFraction(12, 345)+MyFraction(67, 89)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_helper": "subslide_end" }, "scrolled": true, "slide_helper": "slide_end", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "from IPython.display import display_latex\n", "display_latex(MyFraction(12, 345)+MyFraction(67, 89))" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 46, "slide_type": "subslide" }, "slideshow": { "slide_type": "slide" } }, "source": [ "## Interaction with widgets" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 56 }, "scrolled": true, "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "from IPython.html.widgets import interact" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 56 }, "scrolled": true, "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "@interact(x=(0., 10.), y=(0, 10))\n", "def power(y, x=2):\n", " print(x**y)" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 58, "slide_helper": "subslide_end" }, "slide_helper": "subslide_end", "slideshow": { "slide_type": "fragment" } }, "source": [ "#### Data types and their associated widgets\n", "\n", "String (`str`, `unicode`) → Text \n", "Dictionary (`dict`) → Dropdown \n", "Boolean variable (`bool`) → Checkbox \n", "Float (`float`) → FloatSlider \n", "Integer (`int`) → IntSlider" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 58, "slide_helper": "subslide_end", "slide_type": "subslide" }, "scrolled": true, "slide_helper": "subslide_end", "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "@interact(x=(0, 5),\n", " text=\"Python is great!!!\")\n", "def f(text, x=0):\n", " for _ in range(x):\n", " print(text)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "internals": { "frag_helper": "fragment_end", "frag_number": 58, "slide_type": "subslide" }, "scrolled": true, "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "from IPython.html import widgets\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "# otherwise matplotlib graphs will be displayed in an external window\n", "\n", "@interact(harmonics=widgets.IntSlider(min=1, max=10, \n", " description='Number of harmonics',\n", " padding='2ex'),\n", " function=widgets.RadioButtons(options=(\"square\",\n", " \"sawtooth\",\n", " \"triangle\"),\n", " description='Function')\n", " )\n", "def f(harmonics, function):\n", " params = {\"square\": {\"sign\":1, \"stepsize\": 2, \"func\": np.sin, \"power\": 1},\n", " \"sawtooth\": {\"sign\": -1, \"stepsize\": 1, \"func\": np.sin, \"power\": 1},\n", " \"triangle\": {\"sign\": 1, \"stepsize\": 2, \"func\": np.cos, \"power\": 2}\n", " }\n", " p = params[function]\n", " xvals, nvals = np.ogrid[-2*np.pi:2*np.pi:100j, 1:harmonics+1:p[\"stepsize\"]]\n", " yvals = np.sum(p[\"sign\"]**nvals*p[\"func\"](nvals*xvals)/nvals**p[\"power\"],\n", " axis=1)\n", " plt.plot(xvals, yvals)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "internals": { "frag_helper": "fragment_end", "frag_number": 61, "slide_helper": "subslide_end" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "fragment" } }, "source": [ "See also the tutorial by Cyrille Rossant at https://github.com/rossant/euroscipy2014." ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 61, "slide_type": "subslide" }, "slideshow": { "slide_type": "slide" } }, "source": [ "## Transformation of IPython-Notebooks to various output formats" ] }, { "cell_type": "markdown", "metadata": { "internals": { "frag_helper": "fragment_end", "frag_number": 61, "slide_helper": "subslide_end" }, "slide_helper": "slide_end", "slideshow": { "slide_type": "-" } }, "source": [ "`ipython notebook --to` *format* *notebook filename* \n", "\n", "Output formats:\n", "* HTML for presentation with `reveal.js`\n", "* LaTeX, PDF\n", "* Markdown\n", "* Restructured text\n", "* Python\n", "\n", "\n", "Static representation of notebooks: [nbviewer.ipython.org](http://nbviewer.ipython.org \"nbviewer\")" ] } ], "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.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }