Vector classes and utilities
Project description
Vector: arrays of 2D, 3D, and Lorentz vectors
Installation
You can install Vector with pip and conda.
pip install vector
Introduction
Vector is a Python library for 2D and 3D spatial vectors, as well as 4D space-time vectors. It is especially intended for performing geometric calculations on arrays of vectors, rather than one vector at a time in a Python for loop.
Vector is part of the Scikit-HEP project, High Energy Physics (HEP) tools in Python.
Coordinate systems
Vectors may be expressed in any of these coordinate systems:
- the azimuthal plane may be Cartesian
x
y
or polarrho
($\rho$)phi
($\phi$) - the longitudinal axis may be Cartesian
z
, polartheta
($\theta$), or pseudorapidityeta
($\eta$) - the temporal component for space-time vectors may be Cartesian
t
or proper timetau
($\tau$)
in any combination. (That is, 4D vectors have 2×3×2 = 12 distinct coordinate systems.)
Backends
Vectors may be included in any of these data types:
- vector.obj objects (pure Python)
- NumPy structured arrays of vectors
- Awkward Arrays of vectors (possibly within variable-length lists or nested record structures)
- SymPy expressions for symbolic (non-numeric) manipulations
- In Numba-compiled functions, with vector.obj objects or Awkward Arrays
Each of these "backends" provides the same suite of properties and methods, through a common "compute" library.
Geometric versus momentum
Finally, vectors come in two flavors:
- geometric: only one name for each property or method
- momentum: same property or method can be accessed with several synonyms, such as
pt
($p_T$, transverse momentum) for the azimuthal magnituderho
($\rho$) andenergy
andmass
for the Cartesian timet
and proper timetau
($\tau$).
Familiar conventions
Names and coordinate conventions were chosen to align with ROOT's TLorentzVector and Math::LorentzVector, as well as scikit-hep/math, uproot-methods TLorentzVector, henryiii/hepvector, and coffea.nanoevents.methods.vector.
Getting help
- Source code on GitHub: scikit-hep/vector
- Report bugs and request features on the GitHub Issues page
- Ask questions on the GitHub Discussions page
- Real-time chat on Gitter: Scikit-HEP/Vector
Contributing to Vector
If you want to contribute to Vector, pull requests are welcome!
Please install the latest version of the main
branch from source or a fork:
git clone https://github.com/scikit-hep/vector.git
cd vector
pip install -e .
Refer to CONTRIBUTING.md for more.
Citing Vector
@article{Chopra2025,
doi = {10.21105/joss.07791},
url = {https://doi.org/10.21105/joss.07791},
year = {2025}, publisher = {The Open Journal},
volume = {10},
number = {109},
pages = {7791},
author = {Saransh Chopra and Henry Schreiner and Eduardo Rodrigues and Jonas Eschle and Jim Pivarski},
title = {Vector: JIT-compilable mathematical manipulations of ragged Lorentz vectors},
journal = {Journal of Open Source Software}
}
Documentation
Tutorials
- Vector objects
- NumPy arrays of vectors
- Awkward Arrays of vectors
- Compiling functions on vectors with Numba
- Vector expressions with SymPy
Vector constructors
- Making vector objects
- Making NumPy arrays of vectors
- Making Awkward Arrays of vectors
- Making SymPy vector expressions
Vector functions
- Interface for all vectors
- Interface for 2D vectors
- Interface for 3D vectors
- Interface for 4D vectors
- Interface for 2D momentum
- Interface for 3D momentum
- Interface for 4D momentum
More ways to learn
Contributors
Thanks goes to these wonderful people (emoji key):
Jim Pivarski 🚧 💻 📖 |
Henry Schreiner 🚧 💻 📖 |
Eduardo Rodrigues 🚧 💻 📖 |
N!no 📖 |
Peter Fackeldey 📖 |
Luke Kreczko 💻 |
Nicholas Smith 🤔 |
Jonas Eschle 🤔 |
Saransh Chopra 🚧 💻 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome! See CONTRIBUTING.md for information on setting up a development environment.
Acknowledgements
This library was primarily developed by Saransh Chopra, Henry Schreiner, Jim Pivarski, Eduardo Rodrigues, and Jonas Eschle.
Support for this work was provided by the National Science Foundation cooperative agreement OAC-1836650 and PHY-2323298 (IRIS-HEP) and OAC-1450377 (DIANA/HEP). Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file vector-1.6.3.tar.gz
.
File metadata
- Download URL: vector-1.6.3.tar.gz
- Upload date:
- Size: 352.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a85149a62fcaa8a4d95214ca217f3910ea6800d79d65ef1cfb1005720b4f713a
|
|
MD5 |
ab98b4d759e0d194bbccb36f9e493a60
|
|
BLAKE2b-256 |
1295b395e13a19b081d639f567b4013eb70e0bf346c43e3df98f95862a276b16
|
Provenance
The following attestation bundles were made for vector-1.6.3.tar.gz
:
Publisher:
cd.yml
on scikit-hep/vector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
vector-1.6.3.tar.gz
-
Subject digest:
a85149a62fcaa8a4d95214ca217f3910ea6800d79d65ef1cfb1005720b4f713a
- Sigstore transparency entry: 274865351
- Sigstore integration time:
-
Permalink:
scikit-hep/vector@ffd5a6905c9e9f9dc1845326adbdc78f7ef67aae
-
Branch / Tag:
refs/tags/v1.6.3
- Owner: https://github.com/scikit-hep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
cd.yml@ffd5a6905c9e9f9dc1845326adbdc78f7ef67aae
-
Trigger Event:
release
-
Statement type:
File details
Details for the file vector-1.6.3-py3-none-any.whl
.
File metadata
- Download URL: vector-1.6.3-py3-none-any.whl
- Upload date:
- Size: 179.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
cdfbb6d1ea3100db56317812e53bb6aacb9d35fc9fff282066c4cc19fe5aab46
|
|
MD5 |
eabfb1129cb1084b5b4fa99db2361d3b
|
|
BLAKE2b-256 |
bb3e0bdbe6b3a492d89df040f751cdd21505485250c3710b54122a3226fca849
|
Provenance
The following attestation bundles were made for vector-1.6.3-py3-none-any.whl
:
Publisher:
cd.yml
on scikit-hep/vector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
vector-1.6.3-py3-none-any.whl
-
Subject digest:
cdfbb6d1ea3100db56317812e53bb6aacb9d35fc9fff282066c4cc19fe5aab46
- Sigstore transparency entry: 274865359
- Sigstore integration time:
-
Permalink:
scikit-hep/vector@ffd5a6905c9e9f9dc1845326adbdc78f7ef67aae
-
Branch / Tag:
refs/tags/v1.6.3
- Owner: https://github.com/scikit-hep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
cd.yml@ffd5a6905c9e9f9dc1845326adbdc78f7ef67aae
-
Trigger Event:
release
-
Statement type: