[Book Review] Numpy 1.5 Beginner's Guide
Full Disclosure: The publisher of this book, PACKT, was soliciting reviewers. I volunteered to review the book and the publisher sent me an e-version of the book.
The following is a review of "Numpy 1.5 Beginner's Guide", "Learn by doing: less theory, more results" by Ivan Idris. As the title suggests this book is for a beginner. Either someone who is new to numerical computing with high-level languages (HLL) or someone who is new to the Python numerical/scientific packages. Even though the book is targeted for beginners there were some useful (new to me) information in the book. But I don't believe it would be worth the cost of the book if you are familiar with the Python packages; numpy, scipy, matplotlib, and ipython. But if you are new to the Python ecosystem or numerical computing with an HLL this book is worth consideration.
I am going start the review by pointing out two short comings of the book. First, the books title is horrible. Two things wrong with the title. One, the title doesn't do the book justice. The title suggests a narrow introduction to number crunching with Python. And a beginner might not realize what numpy is and that this book may be of use. Someone interested in getting started with Python for analyzing data, numerical computing, etc. might pass this book by because they do not know what numpy is. Two, the title ties to a specific version of numpy, version 1.5. This is detrimental because it suggests the book is already out dated, the latest release of numpy is 1.6.x.
The book really should have been titled, something more along the lines, "Numerical and Scientific Computing with Python, Beginner's Guide" or "Number Crunching with Python, Beginner's Guide".
The second issue, the first chapter reviews installing the packages. But installing the packages makes the same mistake the title does. It only reviews installing the numpy package and does not review installing some of the other packages heavily used in the book. The book relies on the use of ipython, the enhanced interactive shell and matplotlib. Both ipython and matplotlib are used heavily and the installation (and overview) of both these packages should be included in the first chapter. The first chapter does introduce ipython but no installation and it could benefit from an introduction to matplotlib. The good thing, installing the additional packages on most systems is straight-forward.
The writing style of the book ok, the book could have used a second or third review to clean up sentences and paragraphs that are slightly awkward. Also, in the introduction to the book, the History section seems to be inaccurate; it doesn't really agree with the historical perspective provided in the numpybook. Note, the numpybook is a free book which overviews numpy. But the numpybook goes into much more detail and doesn't have as many straight forward examples which Numpy 1.5 Beginner's Guide contains. For an absolute beginner the numpybook (Guide to Numpy) is not the best option.
The book takes a "hands on" approach to introducing number crunching with Python. The book uses a recipe for the examples and code snippets. The format used for the examples, to interactively (hands on) walk the reader through using Python for number crunching starts with the Time for action (the exercise). And then concludes with What just happened and a pop-quiz. This format seems affective for an interactive guide. Since I am familiar with the Python ecosystem it was hard for me to gauge if this format would be useful for a beginner. I did show the example style to a couple colleagues and the format does seem effective. The colleagues were interested in jumping in head first and the exercises in this book would be a good starting point from their opinion.
The book is not a book on signal processing, it is not a book on linear algebra, it is not a book numerical methods. But rather a gentle introduction to a subset of the Python ecosystem for numerical and scientific computing.
Here is a list of the chapters of the book:
- Numpy Quick Start. This chapter reviews numpy installation. As mentioned this chapter should have also included the ipython and matplotlib installations and overview. This chapter has a brief introduction creating a numpy type, an array. But this could have waited for the next chapter and a simple example of doing basic (even more basic) calculations in the ipython shell could have been included. The reason I say this, is because the next chapter introduces the numpy types. For a very green beginner the first example could be meaningless, other than typing in the example. More experienced users can skip this chapter.
- Beginning with Numpy Fundamentals. This chapter introduces the numpy types, mainly the ndarray. This chapter walks through some examples using the ndarray; creating arrays and indexing and slicing. But this chapter mixes terminology. It refers to 2D arrays as matrices. This is bad because numpy has a clear distinction between arrays (N-dimension arrays) and matrices. A matrix, is a mathematical matrix that linear algebra functions are performed on. Arrays are data collections. Example, multiplying arrays and multiplying matrices are two different operations.
- Get into Terms with Commonly Used Functions. This chapter reviews functions that perform operations on arrays. The exercises in this chapter a reader may find interesting and useful. The book, magically introduces plotting. If you are not using a pre-packaged distribution (PythonXY, Enthought, etc) it can be some work setting up the plotting packages (depending on platform etc). For the most part, matplotlib installs effortlessly but using and interactively displaying plots needs some requires understanding and configuration.
- Convenience Functions for Your Convenience. The wording for this chapter title seems wrong, should be "Convenient Functions ..". More functions and examples.
Working with Matrices and ufuncs. As the title suggest, this chapter introduces Matrices. Previously mentioned, in the earlier chapters the author refers to 2D ndarrays as matrices, hence there could be a little confusion at this point. This chapter does a decent job of giving an overview of the matrices. This chapter explains how to develop universal function (ufuncs). The Lissajous curves exercise in this chapter generates some interesting plots but it does not really utilize a matrix, the exercise is completed with ndarrays.
Move Further with Numpy Modules. This chapter illustrates some of the additional functions/packages that are part of the core numpy. This chapter has exercises that walk through solving the eigen vectors for a matrix. Also, an exercise using the FFT which is part of the fftpack in numpy.
- Peeking Into Special Routines. This chapter reviews some other functions, functions for sorting and some financial specific functions. This chapter also has a lengthy section on the window functions available in numpy. Each window function is simply plotted, Other than simply showing these functions exist this chapter does not have much use.
Assure Quality with Testing. This a topic often omitted in similar texts. This is a useful chapter, it introduces some useful ways to test code that might be developed. The chapter discusses unit testing. Often system signal processing Engineers use numerical packages (Matlab, Octave, Scilab, Numpy) for design and analysis. As more complex simulations and tools are developed, having concrete test methods are useful. This chapter reviews some of the available tools for testing with numpy. One of the interesting assertion functions available is assert_almost_equal. This was new to me and this function can be very useful because, I often simulate cycle and bit accurate models and check the response against the design and analysis functions. There is always some discrepancy, allowable/expected error, and this function can aid in testing.
Plotting with Matplotlib. This introduces some more of the plotting routines with matplotlib. Since plotting is such a fundamental package required when doing numerical computing, having a complete and stable package as matplotlib is nice. This chapter and the next support why the title is so horrible. As previously mentioned there should have been a little more of an introduction early on for the plotting.
When Numpy is Not Enough: Scipy and Beyond. The first paragraph in this chapter is incorrect. It states scipy allows sharing of code with Matlab and Octave. Best of my knowledge this is not true, what the author intended to say is that data can be shared (interchanged) via the .mat files. But this might only be true for older versions of Matlab, I believe the format for newer Matlab version has been modified and might not be compatible. This chapter reviews the additional packages (same as toolboxes in Matlab/Octave) in the scipy package. It briefly reviews; File I/O, Statistics, Signal Processing, Optimization, Interpolation, Image Processing.
As mentioned in the opening remarks, if you are new to numerical computing with a high-level language or new to Python and the numerical/scientific packages this book is worth consideration. For a beginner working through the examples in this book, it would be a good introduction to the number crunching with Python. Overall I would only give this book 3 stars out of 5. I believe it is a good introduction for beginners and has useful examples. But because of some of the misdirection and errors it could also cause confusion in the readers journey to discovering Python for numerical and scientific computing.
To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.
Registering will allow you to participate to the forums on ALL the related sites and give you access to all pdf downloads.