Prerequisites & Notation
Before You Begin
This chapter covers NumPy at an intermediate-to-advanced level. You should be comfortable with basic Python data structures, functions, and have a first exposure to NumPy arrays before proceeding.
- Python data structures: lists, tuples, dicts(Review ch01)
Self-check: Can you explain the difference between a list and a tuple?
- Functions, closures, and decorators(Review ch02)
Self-check: Can you write a decorator that times a function call?
- Basic NumPy: creating arrays and element-wise operations
Self-check: Can you create a 1-D array with np.array and compute element-wise sums?
- Basic linear algebra: matrix dimensions, transpose
Self-check: Do you know what shape a (3, 4) matrix has and what its transpose shape is?
- Binary representation of floating-point numbers
Self-check: Do you know that float64 uses 8 bytes per element?
Notation for This Chapter
Symbols and conventions used throughout this chapter.
| Symbol | Meaning | Introduced |
|---|---|---|
The NumPy module (import numpy as np) | s01 | |
Tuple of array dimensions, e.g., (3, 4) for a 3-by-4 matrix | s01 | |
| Bytes to step in each dimension to reach the next element | s01 | |
Data type of array elements (e.g., float64, complex128) | s01 | |
Element at row i, column j (basic indexing returns a view) | s02 | |
Boolean indexing β selects elements where mask is True (returns a copy) | s02 | |
Alias for None; inserts a length-1 axis for broadcasting | s03 | |
| Element-wise (Hadamard) product | s04 | |
A np.random.Generator instance from np.random.default_rng() | s06 |