Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
NumPy Cookbook

You're reading from  NumPy Cookbook

Product type Book
Published in Oct 2012
Publisher Packt
ISBN-13 9781849518925
Pages 226 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

NumPy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Winding Along with IPython Advanced Indexing and Array Concepts Get to Grips with Commonly Used Functions Connecting NumPy with the Rest of the World Audio and Image Processing Special Arrays and Universal Functions Profiling and Debugging Quality Assurance Speed Up Code with Cython Fun with Scikits Index

Running a web notebook


The newest release of IPython introduced a new exciting feature – the web notebook. A so called "notebook server" can serve notebooks over the web. We can now start a notebook server and have a web-based IPython environment. This environment has most of the features in the regular IPython environment. The new features include the following:

  • Displaying images and inline plots

  • Using HTML and Markdown in text cells

  • Importing and exporting of notebooks

Getting ready

Before we start, we should make sure that all the required software is installed. There is a dependency on tornado and zmq. See the Installing IPython recipe in this chapter for more information.

How to do it...

  • Running a notebook: We can start a notebook with the following code:

    $ ipython notebook
    
    [NotebookApp] Using existing profile dir: u'/Users/ivanidris/.ipython/profile_default'
    [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888
    [NotebookApp] Use Control-C to stop this server and shut down all kernels.
    

    As you can see, we are using the default profile. A server started on the local machine at port 8888. We will learn how to configure these settings later on in this chapter. The notebook is opened in your default browser; this is configurable as well:

    IPython lists all the notebooks in the directory where you started the notebook. In this example no notebooks were found. The server can be stopped with Ctrl + C.

  • Running a notebook in the pylab mode: Run a web notebook in the pylab mode with the following command:

    $ ipython notebook --pylab
    

    This loads the Scipy, NumPy, and Matplotlib modules.

  • Running notebook with inline figures: We can display inline Matplotlib plots with the inline directive, using the following command:

    $ ipython notebook --pylab inline
    
  1. Create a notebook: Click on the New Notebook button to create a new notebook:

  2. Create an array: Create an array with the arange function. Type the command in the following screenshot, and press Enter:

    Next, enter the following command and press Enter. You will see the output as shown in Out [2] in the following screenshot:

  3. Plot the sinc function: Apply the sinc function to the array and plot the result, as shown in the following screenshot:

How it works...

The inline option lets you display inline Matplotlib plots. When combined with the pylab mode, you don't need to import the NumPy, SciPy, and Matplotlib packages.

See also

The Installing IPython recipe.

You have been reading a chapter from
NumPy Cookbook
Published in: Oct 2012 Publisher: Packt ISBN-13: 9781849518925
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}