Registry / data / mt2
library1.3.1pypypi✓ verified 83d ago

mt2 provides a fast, numerically stable computation of the stransverse mass (M_T2) as a NumPy universal function (ufunc). It is commonly used in high-energy physics for SUSY searches and dilepton event analysis. Current version: 1.3.1, with release cadence approximately every 3-4 months. Requires Python >=3.9.

pip install mt2
INSTALL
IMPORT
SIG · MT2
M
mt2
datapythonv1.3.1
Install
3.7s avg
Import
257ms
Disk
91MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.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.103.95 runs
installs and imports cleanly · install 0.0s · import 0.254s · 93.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.7s · import 0.260s · 86MB
91MB installed
● package 91MB
Code
Verified usage

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

mt2
import mt2
No submodule or deprecated import path exists. Direct import works.

Compute the stransverse mass for a single event.

import numpy as np import mt2 # Define transverse momenta and masses pa = np.array([100.0, 50.0, 0.0]) # (px, py, m) for visible particle a pb = np.array([80.0, -30.0, 0.0]) # (px, py, m) for visible particle b pt_miss = np.array([20.0, 10.0]) # missing transverse momentum (px, py) m_invis = 0.0 # mass of the invisible particle # Compute M_T2 result = mt2.mt2(pa, pb, pt_miss, m_invis) print(f"M_T2 = {result:.2f}")
Debug
Known issues
breakingIn v1.2.1, numpy 2.0 compatibility was fixed. Older versions (pre-1.2.1) may fail with numpy 2.0.
fix
Upgrade to mt2>=1.2.1 and ensure numpy is compatible (numpy>=1.23,<2.1 recommended).
affects: <1.2.1
breakingIn v1.2.2, the Python source code was moved to src/mt2 to avoid import confusion. Direct imports from the old location (e.g., import mt2 as before) still work, but any references to internal modules may break.
fix
Use standard `import mt2`. If you relied on internal paths, adjust imports accordingly.
affects: >=1.2.2
deprecatedIn v1.2.0, the function signature changed: the argument order was updated for consistency. Old code using positional arguments may break.
fix
Use keyword arguments or check the new signature: mt2(pa, pb, pt_miss, m_invis, ...).
affects: >=1.2.0
gotchaThe `pt_miss` vector must have exactly 2 elements (px, py). Providing a 3-element vector (e.g., (px, py, m)) will cause an error.
fix
Ensure pt_miss is a 1D array of length 2. Use e.g. np.array([px, py]).
affects: all
gotchaNegative masses in input are clipped to zero in v1.3.0 and later. In earlier versions, negative masses might produce undefined results or errors.
fix
Upgrade to >=1.3.0 or explicitly clip negative masses to zero before passing to mt2.
affects: <1.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'mt2'
The package is not installed or installed in an incorrect environment.
fix
Run `pip install mt2` or `conda install -c conda-forge mt2`.
ImportError: numpy.core.multiarray failed to import
A version mismatch between numpy and mt2 (e.g., numpy 2.0.0 with mt2 <1.2.1).
fix
Upgrade mt2 to >=1.2.1 and ensure numpy is compatible: `pip install 'mt2>=1.2.1'`.
ValueError: operands could not be broadcast together with shapes
Input arrays have incompatible shapes. mt2 expects either scalar or 1D arrays of same length or broadcastable shapes.
fix
Reshape inputs to have consistent leading dimensions, ensuring pa, pb, pt_miss are all 1D arrays of same length or broadcastable.
AssertionError: Invalid input dimensions
pa or pb must have exactly 3 elements (px, py, m) and pt_miss exactly 2 elements (px, py). This error arises from wrong shape.
fix
Check shapes: pa.shape == (3,), pb.shape == (3,), pt_miss.shape == (2,). For arrays, ensure last dimension is correct.
Upgrade
Version history
1.3.1latest on PyPI · released Oct 9, 2025
Audit
Dependencies
numpyrequiredCore dependency for ufunc and array operations.
Agent activity
4 hits · last 30 days
node
4
Resources
mt2 — pip install mt2 · libregistry