# NumPy — card for AI agents

Fundamental Python library for numerical computing with arrays and matrices.

Category: ML and data science · PyPI package `numpy` · latest version 2.5.4 (checked 2026-11-01)
Install: `pip install numpy`
License: BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## NumPy
- Import it the standard way: `import numpy as np`.
- Create random numbers with a generator from `np.random.default_rng()`, as the homepage example does.
- Prefer vectorized, indexed and broadcast array operations to Python loops over elements.
- Check the Python version: the 2.5.4 release supports Python 3.12-3.15.
- From 2.5.4, `numpy.linalg.svd` and `numpy.linalg.lstsq` raise for inputs containing infinities. Validate inputs or catch the error, and do not rely on a returned result.
- To run NumPy's own tests after install, have `pytest` available and call `numpy.test()`.

## What it is
- NumPy calls itself "the fundamental package for scientific computing with Python." Its core is an N-dimensional array object. Around that array it provides broadcasting functions, tools for integrating C/C++ and Fortran code, and linear algebra, Fourier transform and random number routines.
- The website says the core is "well-optimized C code", so you write Python and get the speed of compiled code. You work on whole arrays at once through vectorization, indexing and broadcasting, which the site calls "the de-facto standards of array computing today."
- The latest release, 2.5.4, is a patch release. It supports Python 3.12 to 3.15. The repository dates from September 2010. NumPy is for anyone in Python who does numerical work on arrays. The site's ecosystem pages cover machine learning, visualization and a long list of scientific domains, all built on top of it.

## Caveats
- Recent Python only: The 2.5.4 release notes list support for Python 3.12 to 3.15. Projects pinned to older interpreters need an older NumPy.
- Patch releases can change error behavior: Code that passed infinities to `svd` or `lstsq` and got a result back will now see an exception. Add a finiteness check or handle the error.
- MaskedArray fill values reset on dtype change: In 2.5.4, a copied fill_value that the new dtype cannot represent falls back to the default. This can now emit a `ComplexWarning`.
- License metadata is unclear on GitHub: The website says NumPy is under a liberal BSD license. The GitHub repository metadata reports no license. Check the license file yourself if this matters for your project.
- Running the test suite needs extra packages: `numpy.test()` needs pytest. Testing the C API, the Cython API and the property-based tests needs further optional dependencies.

## Numbers (AgentGid data)
- Gid Score: 86.5 (#24 of all tools, 3 of 293 in its category)
- Used in 362 public projects set up for AI coding agents (5.8%)
- Downloads last week: 271,552,265 (as of 2026-11-24), +19.7% over 4 weeks
- GitHub stars: 33,459 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
pandas 52.2%, python-dotenv 45.0%, Requests 44.8%, Pydantic 44.2%, Uvicorn 39.5%, FastAPI 39.2%

## Checked alternatives (same job)
- SciPy: https://agentgid.com/tools/scipy/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/numpy/
- Homepage: https://numpy.org
- Repository: https://github.com/numpy/numpy
- Source: https://github.com/numpy/numpy#readme
- Source: https://github.com/numpy/numpy
- Source: https://github.com/numpy/numpy/releases
- Source: https://numpy.org


## NumPy: fast math on lots of numbers in Python

NumPy is a free Python library that does math on thousands or millions of numbers at once. Your app or your AI assistant's script can get averages and percentiles, draw random samples and compare AI text vectors in a few lines. Most Python data and AI libraries take and return NumPy arrays.

### Where to use it
- Rank search results by meaning: Your app turns each document and the user's question into an AI text vector; NumPy scores every document against the question and returns the closest ones. (idea, not from the official pages)
- Summarise numbers from your logs: Turn a column of page load times or order totals into a median, a 95th percentile and a count of outliers for a status page or a report.
- Pick a fair random test group: Choose 500 users for a new feature or make test data, and get the same picks again next time by fixing the seed.
- Keep computed vectors in a file: Save thousands of AI text vectors to one file after computing them once, and load them back in a moment on the next start.
- Hand data to other libraries: pandas tables, scikit-learn models, image tools and chart libraries all read NumPy arrays, so one format moves through the whole data script.
- Edit pictures as grids of numbers: Load a photo with an image library, brighten it, crop it or swap colours as a grid of pixel numbers, then save it again. (idea, not from the official pages)

### How to start
- Install NumPy into your project's Python environment (Python 3.12 to 3.14 for NumPy 2.5).

```
pip install numpy
```

- Check that it works by printing the installed version.

```
import numpy as np
print(np.__version__)
```

- Make a seeded random generator and draw numbers from it, the way the docs recommend.

```
import numpy as np
rng = np.random.default_rng()
samples = rng.normal(size=2500)
```


### License
Free to use, also in paid and closed-source products, under the BSD-3-Clause license. If you ship NumPy itself inside your product, keep its copyright notice and license text. A few bundled parts use other permissive licenses.

### Good to know
- NumPy 2.5 needs Python 3.12, 3.13 or 3.14; older Pythons only get older NumPy versions.
- Every value in one array has the same type, and an array has a fixed size; growing it makes a new copy.
- NumPy 2 removed or moved about 100 old names, so code from older tutorials can fail until it is updated.
- Never load a NumPy file from a stranger with pickles allowed; such a file can run code on your server.

Checked 2026-11-10 against: https://numpy.org/, https://numpy.org/install/, https://numpy.org/doc/stable/, https://numpy.org/doc/stable/user/whatisnumpy.html, https://numpy.org/doc/stable/user/absolute_beginners.html, https://numpy.org/doc/stable/numpy_2_0_migration_guide.html, https://numpy.org/doc/stable/release/2.5.0-notes.html, https://numpy.org/doc/stable/reference/random/index.html, https://numpy.org/doc/stable/reference/generated/numpy.load.html, https://github.com/numpy/numpy/blob/main/README.md, https://github.com/numpy/numpy/blob/main/LICENSE.txt, https://pypi.org/pypi/numpy/2.5.4/json

### Mistakes to avoid
- Don't: np.float_, np.NaN, np.Inf and other names from NumPy 1.x tutorials → Do: np.float64, np.nan, np.inf; run ruff check --select NPY201 to find the rest (NumPy 2.0 removed about 100 old names; in our run np.float_ raised AttributeError ("was removed in the NumPy 2.0 release. Use np.float64 instead").)
- Don't: np.array(data, copy=False) to avoid a copy → Do: np.asarray(data) (In NumPy 2 copy=False means "never copy" and raises an error when a copy is needed, which it did in our run.)
- Don't: np.random.seed(42) then np.random.rand(...) → Do: rng = np.random.default_rng(42), then rng.random(...), rng.choice(...) (The old global functions still work, but the docs recommend the Generator, which is faster and gets the improvements.)
- Don't: json.dumps({"score": scores[0]}) with a NumPy number inside → Do: json.dumps({"score": float(scores[0])}) or scores[0].item() (NumPy numbers are not plain Python numbers; in our run json.dumps raised TypeError (Object of type float32 is not JSON serializable).)
- Don't: np.load(uploaded_file, allow_pickle=True) → Do: np.load(path) with the default allow_pickle=False for files you did not make (Pickled object arrays can run code when loaded.)

### Questions
- Can I use it in a paid, closed-source app? Yes. The BSD-3-Clause license allows it; when you redistribute NumPy itself, keep its copyright notice and license text.
- Which Python do I need? NumPy 2.5 supports Python 3.12 to 3.14.
- My old code fails with "np.float_ was removed". How do I fix it? Replace the old names using the NumPy 2.0 migration guide (np.float_ becomes np.float64, np.NaN becomes np.nan); the Ruff rule NPY201 can fix many of them for you.
- Is NumPy still maintained? Yes. NumPy 2.5.0 came out on 2026-06-21 and the 2.5.4 package was published on PyPI on 2026-10-10.
- Can I try it before installing anything? Yes. The NumPy home page has an interactive shell that runs in the browser.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
