Atlas · skill

NumPy

NumPy provides multidimensional arrays and numerical operations that underpin much of Python's scientific stack. The competency is reasoning about shapes, data types, broadcasting and memory layout so numerical code computes the intended quantities efficiently and remains correct when dimensions or input values change.

Also searchable as: numpy (python library), numpy library

toolPython Data Libraries

What it is

A NumPy array stores elements with a specified data type and shape. Operations often execute in compiled code over whole arrays, avoiding a Python loop for each element. Broadcasting aligns compatible dimensions, while indexing, slicing and reshaping can produce either views of existing memory or new allocations. Reductions operate along selected axes, and linear algebra routines interpret dimensions according to mathematical conventions. NumPy supplies numerical containers and operations; it does not give columns the business meaning or label alignment found in a DataFrame library.

What the work involves

The practitioner writes down the meaning of each axis, chooses types with adequate precision and uses vectorized operations where they make the computation clearer. They check broadcasting explicitly, distinguish elementwise multiplication from matrix products and understand whether an operation changes shared memory. They profile allocation as well as arithmetic and handle missing or nonfinite values deliberately. A useful numerical component has documented shape contracts, predictable memory behavior and comparisons against a simple reference calculation for representative and boundary inputs.

Illustrative example

An engineer computes distances between a batch of query embeddings and a set of reference vectors. They verify which axis represents samples and which represents embedding coordinates, then choose a batched formula that avoids constructing an unnecessarily large intermediate tensor. A small hand-calculated example checks the distances. Tests with a single query, an empty batch and nearly identical vectors reveal shape and numerical edge cases.

Limits and common mistakes

Broadcasting can yield a valid array with the wrong meaning, while integer arithmetic can overflow and floating-point subtraction can lose precision. Mutating a view may affect another object unexpectedly. Vectorization is not automatically memory-efficient, especially when it creates large intermediates. Check shape assertions, tolerances, allocation and nonfinite results. NumPy array competence is distinct from statistical reasoning about whether the chosen calculation answers the underlying question.

Prerequisites

No prerequisites.

Sources and further reading

  • NumPy user guide

    Documents array creation, dtypes, broadcasting, indexing, copies and views.

Last updated: 2026-10-10