Module 3 Overview
Module 3 — Array Operations & Broadcasting
Welcome
This module is the heart of “thinking in NumPy.” You’ll learn what a ufunc actually is, the broadcasting rules that let arrays of different shapes combine without you writing a single loop, and how to spot — and fix — code that’s secretly looping in disguise.
Learning goals
- Explain what a universal function (ufunc) is and why operators are ufuncs in disguise
- Apply the three broadcasting rules to predict the output shape of an operation
- Rewrite loop-based numeric code as vectorized NumPy
- Use comparison/logical ufuncs and
np.wherefor vectorized conditionals - Build pairwise/outer computations with broadcasting instead of nested loops
- Recognize that
np.vectorizeis a convenience, not a performance tool
Setup — run this first.