PacktLib: NumPy Cookbook

NumPy Cookbook


About the Author

About the Reviewers


Winding Along with IPython


Installing IPython

Using IPython as a shell

Reading manual pages

Installing Matplotlib

Running a web notebook

Exporting a web notebook

Importing a web notebook

Configuring a notebook server

Exploring the SymPy profile

Advanced Indexing and Array Concepts


Installing SciPy

Installing PIL

Resizing images

Creating views and copies

Flipping Lena

Fancy indexing

Indexing with a list of locations

Indexing with booleans

Stride tricks for Sudoku

Broadcasting arrays

Get to Grips with Commonly Used Functions


Summing Fibonacci numbers

Finding prime factors

Finding palindromic numbers

The steady state vector determination

Discovering a power law

Trading periodically on dips

Simulating trading at random

Sieving integers with the Sieve of Erasthothenes

Connecting NumPy with the Rest of the World


Using the buffer protocol

Using the array interface

Exchanging data with MATLAB and Octave

Installing RPy2

Interfacing with R

Installing JPype

Sending a NumPy array to JPype

Installing Google App Engine

Deploying NumPy code in the Google cloud

Running NumPy code in a Python Anywhere web console

Setting up PiCloud

Audio and Image Processing


Loading images into memory map

Combining images

Blurring images

Repeating audio fragments

Generating sounds

Designing an audio filter

Edge detection with the Sobel filter

Special Arrays and Universal Functions


Creating a universal function

Finding Pythagorean triples

Performing string operations with chararray

Creating a masked array

Ignoring negative and extreme values

Creating a scores table with recarray

Profiling and Debugging


Profiling with timeit

Profiling with IPython

Installing line_profiler

Profiling code with line_profiler

Profiling code with the cProfile extension

Debugging with IPython

Debugging with pudb

Quality Assurance


Installing Pyflakes

Performing static analysis with Pyflakes

Analyzing code with Pylint

Speed Up Code with Cython


Installing Cython

Building a Hello World program

Using Cython with NumPy

Calling C functions

Profiling Cython code

Approximating factorials with Cython

Fun with Scikits


Installing scikits-learn

Loading an example dataset

Clustering Dow Jones stocks with scikits-learn

Installing scikits-statsmodels

Performing a normality test with scikits-statsmodels

Installing scikits-image

Detecting corners

Detecting edges

Installing Pandas

Estimating stock returns correlation with Pandas

Loading data as pandas objects from statsmodels

Resampling time series data