Skip to content

Commit 33f2418

Browse files
committed
fix handling for z=0
1 parent d316af4 commit 33f2418

File tree

1 file changed

+13
-2
lines changed
  • src/vector/_compute/spatial

1 file changed

+13
-2
lines changed

src/vector/_compute/spatial/eta.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# or https://github.com/scikit-hep/vector for details.
55

66
import typing
7+
from math import inf, nan
78

89
"""
910
.. code-block:: python
@@ -28,7 +29,12 @@
2829

2930

3031
def xy_z(lib, x, y, z):
31-
return lib.arcsinh(z / lib.sqrt(x**2 + y**2))
32+
return lib.nan_to_num(
33+
lib.arcsinh(z / lib.sqrt(x**2 + y**2)),
34+
nan=lib.nan_to_num((z != 0) * inf, posinf=nan),
35+
posinf=inf,
36+
neginf=-inf,
37+
)
3238

3339

3440
def xy_theta(lib, x, y, theta):
@@ -40,7 +46,12 @@ def xy_eta(lib, x, y, eta):
4046

4147

4248
def rhophi_z(lib, rho, phi, z):
43-
return lib.arcsinh(z / rho)
49+
return lib.nan_to_num(
50+
lib.arcsinh(z / rho),
51+
nan=lib.nan_to_num((z != 0) * inf, posinf=nan),
52+
posinf=inf,
53+
neginf=-inf,
54+
)
4455

4556

4657
def rhophi_theta(lib, rho, phi, theta):

0 commit comments

Comments
 (0)