Open
Description
Some coordinate systems can not represent some vectors. For example, if adding two vectors in pt,phi,eta,E coordinates that have opposite azimuthal components that add to zero, the resulting longitudinal coordinate eta will be infinity:
import numpy as np
import vector
v1 = vector.obj(pt=1, phi=0, eta=1, E=1)
v2 = vector.obj(pt=1, phi=np.pi, eta=1, E=1)
new_vector = v1 + v2 # this vector can not be represented in the pt,phi,eta,E coordinate system
By default, such errors are suppressed in the library
vector/src/vector/_compute/lorentz/add.py
Line 201 in 69d0b1d
Without that line, the default Numpy error would be shown
/usr/lib/python3.10/site-packages/vector/_compute/spatial/eta.py:43: RuntimeWarning: divide by zero encountered in arctanh
return lib.nan_to_num(lib.arctanh(z / lib.sqrt(rho ** 2 + z ** 2)), nan=0.0)
vector.obj(pt=1.2246467991473532e-16, phi=1.5707963267948966, eta=1.7976931348623157e+308, E=2)
I think it would be better if the user is made aware of the error by default (rather than suppressing by default). Additionally, that leaves the choice of suppressing errors or not to the user, by adding numpy.errstate(all="ignore")
in their code.
Metadata
Metadata
Assignees
Labels
No labels