Advanced Array Concepts

In this chapter, we will explain some more advanced aspects of arrays. First, we will cover the notion of an array view – a concept that a NumPy programmer absolutely must be aware of to avoid hard-to-debug programming errors. Then, Boolean arrays will be introduced along with the ways to compare arrays. Furthermore, we will briefly describe indexing and vectorization, explaining special topics such as broadcasting and sparse matrices.

In this chapter, we will be covering the following topics:

  • Array views and copies
  • Comparing arrays
  • Array indexing
  • Performance and vectorization
  • Broadcasting 
  • Sparse matrices

5.1 Array views and copies

In order to control precisely how memory is used, NumPy offers the concept of a view of ...

Get Scientific Computing with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.