Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/vector/_compute/spatial/eta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# or https://github.com/scikit-hep/vector for details.

import typing
from math import inf, nan

"""
.. code-block:: python
Expand All @@ -29,8 +30,11 @@

def xy_z(lib, x, y, z):
return lib.nan_to_num(
lib.arctanh(z / lib.sqrt(x**2 + y**2 + z**2)), nan=0.0
) * lib.absolute(lib.sign(z))
lib.arcsinh(z / lib.sqrt(x**2 + y**2)),
nan=lib.nan_to_num((z != 0) * inf, posinf=nan),
posinf=inf,
neginf=-inf,
)


def xy_theta(lib, x, y, theta):
Expand All @@ -43,8 +47,11 @@ def xy_eta(lib, x, y, eta):

def rhophi_z(lib, rho, phi, z):
return lib.nan_to_num(
lib.arctanh(z / lib.sqrt(rho**2 + z**2)), nan=0.0
) * lib.absolute(lib.sign(z))
lib.arcsinh(z / rho),
nan=lib.nan_to_num((z != 0) * inf, posinf=nan),
posinf=inf,
neginf=-inf,
)


def rhophi_theta(lib, rho, phi, theta):
Expand Down
2 changes: 1 addition & 1 deletion tests/backends/test_awkward.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_projection():
{
"rho": 6.4031242374328485,
"phi": 0.8960553845713439,
"eta": 0.8361481196083127,
"eta": 0.8361481196083128,
"tau": 0,
"wow": 123,
}
Expand Down
3 changes: 3 additions & 0 deletions tests/test_compute_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ def analyze_callable(node, context):
"arctan2",
"sinh",
"cosh",
"tanh",
"arcsinh",
"arccosh",
"arctanh",
"isclose",
]