Skip to main content

Vector classes and utilities

Project description

Vector logo

Vector: arrays of 2D, 3D, and Lorentz vectors

DOI DOI Scikit-HEP

Actions Status Documentation Status pre-commit.ci status codecov percentage

PyPI platforms PyPI version Conda latest release

LICENSE GitHub Discussion Gitter

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 polar rho ($\rho$) phi ($\phi$)
  • the longitudinal axis may be Cartesian z, polar theta ($\theta$), or pseudorapidity eta ($\eta$)
  • the temporal component for space-time vectors may be Cartesian t or proper time tau ($\tau$)

in any combination. (That is, 4D vectors have 2×3×2 = 12 distinct coordinate systems.)

Diagram of coordinate systems

Backends

Vectors may be included in any of these data types:

Each of these "backends" provides the same suite of properties and methods, through a common "compute" library.

Integrations

Optionally, the vector package provides integration with other libraries. Currently, this includes:

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 magnitude rho ($\rho$) and energy and mass for the Cartesian time t and proper time tau ($\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

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

To cite Vector, please use DOI

@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 constructors

Vector functions

Integrations

More ways to learn

Contributors

Thanks goes to these wonderful people (emoji key):

Jim Pivarski
Jim Pivarski

🚧 💻 📖
Henry Schreiner
Henry Schreiner

🚧 💻 📖
Eduardo Rodrigues
Eduardo Rodrigues

🚧 💻 📖
N!no
N!no

📖
Peter Fackeldey
Peter Fackeldey

📖
Luke Kreczko
Luke Kreczko

💻
Nicholas Smith
Nicholas Smith

🤔
Jonas Eschle
Jonas Eschle

🤔
Saransh Chopra
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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vector-1.8.1.tar.gz (388.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vector-1.8.1-py3-none-any.whl (182.7 kB view details)

Uploaded Python 3

File details

Details for the file vector-1.8.1.tar.gz.

File metadata

  • Download URL: vector-1.8.1.tar.gz
  • Upload date:
  • Size: 388.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vector-1.8.1.tar.gz
Algorithm Hash digest
SHA256 1b7658a4fbc7b593342506a1b84eff3459745b09c98c3be83ed58df31fd29b43
MD5 207795dc1e27430858d3362fe24dc585
BLAKE2b-256 ee2c5f3d3617f86f0170a4c3553d82983eb3c81b1765225dc74455cf9176cdd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for vector-1.8.1.tar.gz:

Publisher: cd.yml on scikit-hep/vector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vector-1.8.1-py3-none-any.whl.

File metadata

  • Download URL: vector-1.8.1-py3-none-any.whl
  • Upload date:
  • Size: 182.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vector-1.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e7f66f6aa7fb40ccb68a8c5c172a99bf8985cce31e4cdb9a9f39ad1de33027
MD5 aeb282ac904e2543f0f38bdbfb02cd68
BLAKE2b-256 c673582abcd8d4439f4898969cac8aae998c74b28e79e6bd2cfc7d1516bc4518

See more details on using hashes here.

Provenance

The following attestation bundles were made for vector-1.8.1-py3-none-any.whl:

Publisher: cd.yml on scikit-hep/vector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page