Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare vector results with ROOT's. #87

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ jobs:
- name: Test package
run: python -m pytest -ra

# root:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
root:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# - name: Get Conda
# uses: conda-incubator/setup-miniconda@v2
# with:
# environment-file: environment.yml
# activate-environment: vector
- name: Get Conda
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment.yml
activate-environment: vector

# - name: Run tests
# shell: "bash -l {0}"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"awkward": ["awkward>=1.2.0"],
"test": [
"pytest>=4.6",
"hypothesis>=6",
],
"test_extras": [
"uncompyle6",
Expand Down
9 changes: 5 additions & 4 deletions src/vector/_compute/lorentz/dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ def make_conversion(
to_t2 = t.rhophi_eta_tau

def f(lib, coord11, coord12, coord13, coord14, coord21, coord22, coord23, coord24):
return lib.absolute(
to_t1(lib, coord11, coord12, coord13, coord14)
* to_t2(lib, coord21, coord22, coord23, coord24)
) - spatial_dot(lib, coord11, coord12, coord13, coord21, coord22, coord23)
t1 = to_t1(lib, coord11, coord12, coord13, coord14)
t2 = to_t1(lib, coord21, coord22, coord23, coord24)
return (t1 * t2) - spatial_dot(
lib, coord11, coord12, coord13, coord21, coord22, coord23
)

dispatch_map[
azimuthal1, longitudinal1, temporal1, azimuthal2, longitudinal2, temporal2
Expand Down
1 change: 1 addition & 0 deletions src/vector/_compute/spatial/mag2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def xy_z(lib, x, y, z):


def xy_theta(lib, x, y, theta):
# FIXME?: returns 'nan' when theta == 0.0
return (x ** 2 + y ** 2) / lib.sin(theta) ** 2


Expand Down
85 changes: 85 additions & 0 deletions tests/root/test_EulerAngles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright (c) 2019-2021, Jonas Eschle, Jim Pivarski, Eduardo Rodrigues, and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/vector for details.

import pytest
from hypothesis import given
from hypothesis import strategies as st

import vector

# If ROOT is not available, skip these tests.
ROOT = pytest.importorskip("ROOT")

# 4D constructor arguments to get all the weird cases.
constructor = [
(0, 0, 0, 0),
(0, 0, 1, 0), # theta == 0.0
(0, 0, -1, 0),
(0, 0, 1, 0),
(0, 0, 0, 4294967296),
(0, 4294967296, 0, 0),
(0, 0, 0, 10),
(0, 0, 0, -10),
(1, 2, 3, 0),
(1, 2, 3, 10),
(1, 2, 3, -10),
(1.0, 2.0, 3.0, 2.5),
(1, 2, 3, 2.5),
(1, 2, 3, -2.5),
]

# Coordinate conversion methods to apply to the VectorObject4D.
coordinate_list = [
"to_xyzt",
"to_xythetat", # may fail for constructor2
"to_xyetat",
"to_rhophizt",
"to_rhophithetat",
"to_rhophietat",
"to_xyztau",
"to_xythetatau",
"to_xyetatau",
"to_rhophiztau",
"to_rhophithetatau",
"to_rhophietatau",
]


@pytest.fixture(scope="module", params=coordinate_list)
def coordinates(request):
return request.param


angle_list = [
0,
0.0,
0.7853981633974483,
-0.7853981633974483,
1.5707963267948966,
-1.5707963267948966,
3.141592653589793,
-3.141592653589793,
6.283185307179586,
-6.283185307179586,
]


@pytest.fixture(scope="module", params=angle_list)
def angle(request):
return request.param


scalar_list = [
0,
-1,
1.0,
100000.0000,
-100000.0000,
]


@pytest.fixture(scope="module", params=scalar_list)
def scalar(request):
return request.param
Loading