![]()
Learning IPython for Interactive Computing and Data Visualization
Table of Contents
Learning IPython for Interactive Computing and Data Visualization
Credits
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with IPython
Installing IPython and the recommended packages
Prerequisites for IPython
Installing an all-in-one distribution
Installing the packages one by one
Packages websites
Getting binary installers
Windows
OS X
Linux
Table of binary packages
Using the Python packaging system
Optional dependencies for IPython
Installing the development versions
Ten IPython essentials
Running the IPython console
Using IPython as a system shell
Using the history
Tab completion
Executing a script with the %run command
Quick benchmarking with the %timeit command
Quick debugging with the %debug command
Interactive computing with Pylab
Using the IPython Notebook
Customizing IPython
Summary
2. Interactive Work with IPython
The extended shell
Navigating through the filesystem
Accessing the system shell from IPython
The extended Python console
Exploring the history
Import/export of Python code
Importing code in IPython
Exporting code to a file
Dynamic introspection
Tab completion
An example of tab completion NetworkX
Tab completion with custom classes
Source code introspection
Using the interactive debugger
Interactive benchmarking and profiling
Controlling the execution time of a command
Profiling a script
Using the IPython notebook
Installation
The notebook dashboard
Working with cells
Cell magics
Managing notebooks
Multimedia and rich text editing
Graph plotting
Summary
3. Numerical Computing with IPython
A primer to vector computing
An example of computation with Python loops
What an array is
Reimplementing the example with arrays
Creating and loading arrays
Creating arrays
From scratch, element by element
From scratch, using predefined templates
From random values
Loading arrays
From a native Python object
From a buffer or an external file
Using Pandas
Working with arrays
Selection
Using Pandas
Using NumPy
More indexing possibilities
Manipulation
Reshaping
Repeating and concatenating
Broadcasting
Permuting
Computation
Advanced mathematical processing
Summary
4. Interactive Plotting and Graphical Interfaces
Figures with Matplotlib
Setting up IPython for interactive visualization
Using Matplotlib
Interactive navigation
Matplotlib in the IPython notebook
Standard plots
Curves
Scatter plots
Bar graphs
Plot customization
Styles and colors
Grid, axes, and legends
Interaction from IPython
Drawing multiple plots
Advanced figures and graphics
Image processing
Loading images
Showing images
Using PIL
Advanced image processing – color quantization
Maps
3D plots
Animations
Other visualization packages
Graphical User Interfaces (GUI)
Setting up IPython for interactive GUIs
A "Hello World" example
Summary
5. High-Performance and Parallel Computing
Interactive task parallelization
Parallel computing in Python
Distributing tasks on multiple cores
Starting the engines
Creating a Client instance
Using the parallel magic
Parallel map
Creating a view
Synchronous map
Asynchronous map
A practical example – Monte Carlo simulations
Using MPI with IPython
Advanced parallel computing features of IPython
Using C in IPython with Cython
Installing and configuring Cython
Using Cython from IPython
Accelerating a pure Python algorithm with Cython
Pure Python version
Naïve Cython conversion
Adding C types
Using NumPy and Cython
Python version
Cython version
More advanced options for accelerating Python code
Summary
6. Customizing IPython
IPython profiles
Profile locations
The IPython configuration files
Loading scripts when IPython starts
IPython extensions
Example – line-by-line profiling
Creating new extensions
Example – executing C++ code in IPython
Rich representations in the frontend
Embedding IPython
Final words
Summary
Index
![]()
Learning IPython for Interactive Computing and Data Visualization
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. H...