Registry / data / vector

vector

JSON →
library1.8.1pypypi✓ verified 25d ago

The Vector library provides classes and utilities for representing 2D, 3D, and 4D vectors, primarily for scientific computing, especially within the Scikit-HEP ecosystem. It offers a NumPy-compatible interface for vector operations, with support for various backends including pure Python objects, NumPy arrays, Awkward Arrays, and Numba for JIT-compiled calculations. The current version is 1.8.0, and it maintains a regular release cadence with several minor versions released annually.

pip install vector
INSTALL
IMPORT
SIG · VECTOR
V
vector
datapythonv1.8.1
Install
3.9s avg
Import
344ms
Disk
93MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.344s · 92.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.9s · import 0.344s · 89MB
93MB installed
● package 93MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vector
✓ import vector
The main entry point for creating vector objects and accessing utilities.
vector.obj
✓ my_vec = vector.obj(x=1, y=2)
Used to create a single pure Python vector object.
vector.arr
✓ vec_array = vector.arr(x=[1,2,3], y=[4,5,6])
Used to create a NumPy array of vector objects. Also accessible via `vector.array`.
vector.awk
✓ awk_array = vector.awk(x=ak.Array([1,2]), y=ak.Array([3,4]))
Used to create an Awkward Array of vector objects. Also accessible via `vector.Array`.

This quickstart demonstrates how to import the `vector` library, create 2D and 4D vector objects using `vector.obj()`, access common properties like magnitude (`rho`) and transverse momentum (`pt`), perform vector addition, and calculate angular differences like `delta_phi`.

import vector # Create a 2D Cartesian vector v2d = vector.obj(x=3, y=4) print(f"2D vector: {v2d}") print(f"Magnitude: {v2d.rho}") # Create a 4D Lorentz vector (momentum-like) v4d = vector.obj(px=10, py=20, pz=30, mass=5) print(f"4D vector (momentum): {v4d}") print(f"Transverse momentum: {v4d.pt}") # Add two vectors v_sum = v2d + vector.obj(x=1, y=1) print(f"Vector sum: {v_sum}") # Calculate delta_phi between two 2D vectors v1 = vector.obj(x=1, y=0) v2 = vector.obj(x=0, y=1) delta_phi = v1.delta_phi(v2) print(f"Delta phi between v1 and v2: {delta_phi}")
Debug
Known issues
breakingSupport for older Python versions has been dropped in recent releases. Vector v1.8.0 requires Python 3.10+, and v1.7.0 dropped Python 3.8 support. Users on older Python environments must use an earlier version of the `vector` library.
fix
Upgrade to Python 3.10 or newer, or pin `vector` to an earlier compatible version (e.g., `<1.7.0` for Python 3.8, `<1.8.0` for Python 3.9).
affects: >=1.7.0
breakingSupport for Awkward Array v1 was removed in `vector` v1.5.0. If you use `vector` with Awkward Arrays, you must upgrade to Awkward Array v2 or later.
fix
Ensure your project uses Awkward Array v2 (e.g., `pip install 'awkward>=2.0.0'`).
affects: >=1.5.0
gotchaVersion 1.6.0 of the `vector` library was yanked from PyPI shortly after its release due to a bug where `numpy` functions were incorrectly called on `TypeTracerArray`s. It is recommended to avoid this specific version.
fix
If `vector==1.6.0` is in your dependencies, upgrade to `vector>=1.6.1` or the latest stable version.
affects: 1.6.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'vector'
The 'vector' library has not been installed in the current Python environment.
fix
pip install vector
AttributeError: module 'vector' has no attribute 'x'
The coordinate 'x' is an attribute of a 'vector' instance (e.g., a 2D vector object), not a property directly accessible from the top-level 'vector' module.
fix
Create a vector object first, then access its attributes: `v = vector.obj(x=1, y=2); print(v.x)`
TypeError: obj() missing 2 required keyword-only arguments: 'x' and 'y'
When creating a 2D vector using `vector.obj()`, the required coordinate arguments (e.g., 'x' and 'y' for Cartesian, or 'rho' and 'phi' for polar) were not provided as keyword arguments.
fix
Provide the required coordinates as keyword arguments: `v = vector.obj(x=1.0, y=2.0)` or `v = vector.obj(rho=1.0, phi=0.5)`
ValueError: array must be an Awkward Array, NumPy structured array, or an object that contains either 'x', 'y', 'z', 't', 'rho', 'phi', 'theta', 'tau', 'px', 'py', 'pz', 'E', 'eta', 'rapidity', 'pt'
When attempting to create a 'vector.Array' from a NumPy array, the input array was not in the expected structured format with named fields for vector components (e.g., 'x', 'y').
fix
Ensure the input NumPy array is a structured array with fields corresponding to vector components, or use `vector.Array.from_fields()` for explicit control: `import numpy as np; import vector; arr = np.array([{'x': 1, 'y': 2}, {'x': 3, 'y': 4}]); v_arr = vector.Array(arr)`
Upgrade
Version history
1.8.1latest on PyPI · released May 21, 2026
Audit
Dependencies
pythonrequiredRequires Python >=3.10. Older versions of the library supported older Python versions (e.g., v0.9.0 supported 3.6+).
numpyrequiredCore dependency for array-based vector operations and numerical computations.
awkwardoptionalOptional backend for manipulating arrays of vectors with Awkward Array. Requires Awkward Array v2+ since vector v1.5.0.
numbaoptionalOptional backend for JIT-compiled calculations on vectors, particularly with NumPy and Awkward Arrays.
sympyoptionalOptional backend for symbolic (non-numeric) manipulations of vector expressions.
Agent activity
40 hits · last 30 days
node
36
OpenAI (training)
1
Resources
vector — pip install vector · libregistry