07-07, 08:00–12:00 (US/Pacific), Room 315
Despite its reputation for being slow, Python is the leading language of scientific computing, which generally needs large-scale (fast) computations. This is because most scientific problems can be split into "metadata bookkeeping" and "number crunching," where the latter is performed by array-oriented (vectorized) calls into precompiled routines.
This tutorial is an introduction to array-oriented programming. We'll focus on techniques that are equally useful in any array library, with a particular focus on NumPy and JAX. You'll work in groups on four class projects: Conway's Game of Life using arrays, iterative computations on arrays, just-in-time (JIT) compilation for the Mandelbrot set, and exploring data in ragged arrays.
Array-oriented programming is a paradigm in its own right, challenging us to think about problems in a different way. From APL in 1966 to NumPy and ML libraries today, most users of array-oriented programming are scientists, analyzing or simulating data. This tutorial focuses on the thought process: all of the problems are to be solved in an imperative way (for loops) and an array-oriented way. Matplotlib will be used for plotting, but all plotting commands will be given (not prerequisites).
We'll interleave four short lectures with four group projects (3‒4 people each), each followed by their solutions, while the problems are still fresh in mind. Tutors will be available for help during each of the group projects.
Here is a general outline:
- 0:00‒0:15 (15 min) Lecture 1: Array-oriented programming and its benefits
- 0:15‒0:35 (20 min) Project 1: Conway’s Game of Life using arrays
- 0:35‒0:45 (10 min) Break
- 0:45‒1:00 (15 min) Solutions to project 1
- 1:00‒1:15 (15 min) Lecture 2: Disadvantages of array-oriented programming
- 1:15‒1:35 (20 min) Project 2: Iterative computations on arrays
- 1:35‒1:45 (10 min) Break
- 1:45‒2:00 (15 min) Solutions to project 2
- 2:00‒2:15 (15 min) Lecture 3: JIT-compilation with Numba and JAX
- 2:15‒2:35 (20 min) Project 3: JIT-compilation of the Mandelbrot set
- 2:35‒2:45 (10 min) Break
- 2:45‒3:00 (15 min) Solutions to project 3
- 3:00‒3:15 (15 min) Lecture 4: Ragged and deeply nested arrays
- 3:15‒3:35 (20 min) Project 4: Exploring data in ragged arrays
- 3:35‒3:45 (10 min) Break
- 3:45‒4:00 (15 min) Solutions to project 4
Prerequisites: participants should have a basic familiarity with Python and NumPy, such as the content of the "Introduction to Numerical Computing with NumPy" tutorial.
We will provide an environment.yml with all of the necessary software packages (CPU only), along with instructions to run it on a VM in the cloud (GitHub Codespaces and possibly others).
Prerequisites –Participants should have a basic familiarity with Python and NumPy, such as the content of the "Introduction to Numerical Computing with NumPy" tutorial.