{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%pylab inline" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here are some basic \u2014 and some more surprising \u2014 features of the iPython Notebook\n", "that has been used to build this collection of astronomy examples." ] }, { "cell_type": "code", "collapsed": false, "input": [ ">>> n = 0\n", ">>> for i in range(5):\n", "... n += i\n", "... \n", ">>> print n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# Exception tracebacks are attractive, detailed!\n", "\n", "plot([1, 2, 3], [4, 5, 'a'])" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "!pwd" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "!cal 1 2013" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "files = !ls /usr/bin" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "%load spectral_classification.py" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# See examples at http://matplotlib.org/gallery.html\n", "\n", "%load http://matplotlib.org/mpl_examples/api/radar_chart.py" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "%timeit '-'.join(('abc', 'def', 'ghi'))\n", "%timeit '-'.join(['abc', 'def', 'ghi'])" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import Image, HTML, Latex, YouTubeVideo" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "f = 'venv/lib/python2.7/site-packages/pyface/images/about.jpg'\n", "Image(filename=f)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "HTML('')" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "YouTubeVideo('F4rFuIb1Ie4') # Fernando P\u00e9rez at PyConCA" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "from sympy.interactive import init_printing\n", "init_printing()\n", "\n", "from sympy import *\n", "x, y = symbols('x y')\n", "eq = ((x + y)**2 * (x + 1))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "eq" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "expand(eq)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "Latex(r'The Taylor series for $e^x$ is:'\n", " r'$$\\sum_{x=0}^\\infty {x^n / n!}$$')" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## XKCD Style\n", "\n", "Recently, @jakevdp decided that his example plots looked too serious,\n", "and wanted them to look more like hand-drawn plots in xkcd.\n", "\n", "http://jakevdp.github.com/blog/2012/10/07/xkcd-style-plots-in-matplotlib/" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }