{"id":5823,"library":"vector","title":"Vector","description":"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.","status":"active","version":"1.8.0","language":"en","source_language":"en","source_url":"https://github.com/scikit-hep/vector","tags":["physics","mathematics","vectors","scikit-hep","numba","awkward","geometry","lorentz"],"install":[{"cmd":"pip install vector","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python >=3.10. Older versions of the library supported older Python versions (e.g., v0.9.0 supported 3.6+).","package":"python","optional":false},{"reason":"Core dependency for array-based vector operations and numerical computations.","package":"numpy","optional":false},{"reason":"Optional backend for manipulating arrays of vectors with Awkward Array. Requires Awkward Array v2+ since vector v1.5.0.","package":"awkward","optional":true},{"reason":"Optional backend for JIT-compiled calculations on vectors, particularly with NumPy and Awkward Arrays.","package":"numba","optional":true},{"reason":"Optional backend for symbolic (non-numeric) manipulations of vector expressions.","package":"sympy","optional":true}],"imports":[{"note":"The main entry point for creating vector objects and accessing utilities.","symbol":"vector","correct":"import vector"},{"note":"Used to create a single pure Python vector object.","symbol":"vector.obj","correct":"my_vec = vector.obj(x=1, y=2)"},{"note":"Used to create a NumPy array of vector objects. Also accessible via `vector.array`.","symbol":"vector.arr","correct":"vec_array = vector.arr(x=[1,2,3], y=[4,5,6])"},{"note":"Used to create an Awkward Array of vector objects. Also accessible via `vector.Array`.","symbol":"vector.awk","correct":"awk_array = vector.awk(x=ak.Array([1,2]), y=ak.Array([3,4]))"}],"quickstart":{"code":"import vector\n\n# Create a 2D Cartesian vector\nv2d = vector.obj(x=3, y=4)\nprint(f\"2D vector: {v2d}\")\nprint(f\"Magnitude: {v2d.rho}\")\n\n# Create a 4D Lorentz vector (momentum-like)\nv4d = vector.obj(px=10, py=20, pz=30, mass=5)\nprint(f\"4D vector (momentum): {v4d}\")\nprint(f\"Transverse momentum: {v4d.pt}\")\n\n# Add two vectors\nv_sum = v2d + vector.obj(x=1, y=1)\nprint(f\"Vector sum: {v_sum}\")\n\n# Calculate delta_phi between two 2D vectors\nv1 = vector.obj(x=1, y=0)\nv2 = vector.obj(x=0, y=1)\ndelta_phi = v1.delta_phi(v2)\nprint(f\"Delta phi between v1 and v2: {delta_phi}\")","lang":"python","description":"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`."},"warnings":[{"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).","message":"Support 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.","severity":"breaking","affected_versions":">=1.7.0"},{"fix":"Ensure your project uses Awkward Array v2 (e.g., `pip install 'awkward>=2.0.0'`).","message":"Support 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.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"If `vector==1.6.0` is in your dependencies, upgrade to `vector>=1.6.1` or the latest stable version.","message":"Version 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.","severity":"gotcha","affected_versions":"1.6.0"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}