Skip to Content
Beautiful Code
book

Beautiful Code

by Andy Oram, Greg Wilson
June 2007
Intermediate to advanced
618 pages
18h 15m
English
O'Reilly Media, Inc.
Content preview from Beautiful Code

Chapter 19. Multidimensional Iterators in NumPy

Travis E. Oliphant

Numpy is an optional package for the python language that provides a powerful N-dimensional array object. An N-dimensional array is a data structure that uses N integers, or indices, to access individual elements. It is a useful model for a wide variety of data processed by a computer.

For example, a one-dimensional array can store the samples of a sound wave, a two-dimensional array can store a grayscale image, a three-dimensional array can store a color image (with one of the dimensions having a length of 3 or 4), and a four-dimensional array can store the value of pressure in a room during a concert. Even higher-dimensional arrays are often useful.

NumPy provides an environment for the mathematical and structural manipulation of arrays of arbitrary dimensions. These manipulations are at the heart of much scientific, engineering, and multimedia code that routinely deals with large amounts of data. Being able to perform these mathematical and structural manipulations in a high-level language can considerably simplify the development and later reuse of these algorithms.

NumPy provides an assortment of mathematical calculations that can be done on arrays, as well as providing very simple syntax for structural operations. As a result, Python (with NumPy) can be successfully used for the development of significant and fast-performing engineering and scientific code.

One feature that allows fast structural manipulation ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Good Code, Bad Code

Good Code, Bad Code

Tom Long
The Art of Clean Code

The Art of Clean Code

Christian Mayer
Strange Code

Strange Code

Ronald T. Kneusel
Five Lines of Code

Five Lines of Code

Christian Clausen

Publisher Resources

ISBN: 9780596510046Supplemental ContentErrata Page