Arrays: NumPy and SciPy
An array is a flat block of memory plus a few numbers that say how to read it. Learn those numbers and views, broadcasting, vectorisation and SciPy stop being magic.
45 min
After this lesson you can
- Describe an ndarray as a buffer plus dtype, shape, strides and offset, and compute the strides of any C-ordered array
- Predict whether slicing, transposing or reshaping gives a view or a copy
- Apply NumPy's broadcasting rule to two shapes, and explain it as a stride of zero
- Explain why a Python loop is slow and a vectorised call is fast, and what BLAS and LAPACK do underneath
- Use SciPy for linear algebra, optimisation (BFGS, L-BFGS-B), sparse matrices, statistics and signals
In this lesson
- What an array really is
- Views and copies
- Broadcasting: arithmetic between different shapes
- Why loops are slow and vectorised code is fast
- BLAS and LAPACK: the libraries underneath
- SciPy: the algorithms on top
This lesson is part of Descent Pro
Descent Pro unlocks every lesson on the route, from base camp to the summit. Every plan starts with a free trial.