Skip to content

Commit c00b258

Browse files
authored
Constrain the allowed set of language features in 'compute' functions. (#38)
* Constrain the allowed set of language features in 'compute' functions. * Only run that test on Python 3.8. * Black.
1 parent 63efa8c commit c00b258

File tree

8 files changed

+356
-10
lines changed

8 files changed

+356
-10
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

28+
- name: Check compute features only on Python 3.8
29+
if: "matrix.python-version == 3.8"
30+
run: python -m pip install uncompyle6 spark-parser
31+
2832
- name: Requirements check
2933
run: python -m pip list
3034

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ where = src
4545
addopts = -vv -rs -Wd
4646
testpaths =
4747
tests
48+
markers =
49+
slow
4850

4951
[tool:isort]
5052
profile = black

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"scikit-hep-testdata>=0.2.0",
1515
"pytest>=4.6",
1616
],
17-
"test": ["pytest>=4.6"],
17+
"test": [
18+
"pytest>=4.6",
19+
],
1820
}
1921

2022
extras["all"] = sum(extras.values(), [])

src/vector/compute/spatial/costheta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def xy_z(lib, x, y, z):
22-
return lib.nan_to_num(z / mag.xy_z(lib, x, y, z), 1.0)
22+
return lib.nan_to_num(z / mag.xy_z(lib, x, y, z), nan=1.0)
2323

2424

2525
def xy_theta(lib, x, y, theta):
@@ -31,7 +31,7 @@ def xy_eta(lib, x, y, eta):
3131

3232

3333
def rhophi_z(lib, rho, phi, z):
34-
return lib.nan_to_num(z / mag.rhophi_z(lib, rho, phi, z), 1.0)
34+
return lib.nan_to_num(z / mag.rhophi_z(lib, rho, phi, z), nan=1.0)
3535

3636

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

src/vector/compute/spatial/cottheta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
def xy_z(lib, x, y, z):
23-
return lib.nan_to_num(z / rho.xy(lib, x, y), lib.inf)
23+
return lib.nan_to_num(z / rho.xy(lib, x, y), nan=lib.inf)
2424

2525

2626
def xy_theta(lib, x, y, theta):
@@ -32,7 +32,7 @@ def xy_eta(lib, x, y, eta):
3232

3333

3434
def rhophi_z(lib, rho, phi, z):
35-
return lib.nan_to_num(z / rho, lib.inf)
35+
return lib.nan_to_num(z / rho, nan=lib.inf)
3636

3737

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

src/vector/compute/spatial/eta.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818

1919

2020
def xy_z(lib, x, y, z):
21-
return lib.nan_to_num(lib.arctanh(z / lib.sqrt(x ** 2 + y ** 2 + z ** 2)), 0.0)
21+
return lib.nan_to_num(lib.arctanh(z / lib.sqrt(x ** 2 + y ** 2 + z ** 2)), nan=0.0)
2222

2323

2424
def xy_theta(lib, x, y, theta):
25-
return lib.nan_to_num(-lib.log(lib.tan(0.5 * theta)), 0.0)
25+
return lib.nan_to_num(-lib.log(lib.tan(0.5 * theta)), nan=0.0)
2626

2727

2828
def xy_eta(lib, x, y, eta):
2929
return eta
3030

3131

3232
def rhophi_z(lib, rho, phi, z):
33-
return lib.nan_to_num(lib.arctanh(z / lib.sqrt(rho ** 2 + z ** 2)), 0.0)
33+
return lib.nan_to_num(lib.arctanh(z / lib.sqrt(rho ** 2 + z ** 2)), nan=0.0)
3434

3535

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

src/vector/compute/spatial/z.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def xy_z(lib, x, y, z):
2323

2424

2525
def xy_theta(lib, x, y, theta):
26-
return lib.nan_to_num(rho.xy(lib, x, y) / lib.tan(theta), 0.0)
26+
return lib.nan_to_num(rho.xy(lib, x, y) / lib.tan(theta), nan=0.0)
2727

2828

2929
def xy_eta(lib, x, y, eta):
@@ -35,7 +35,7 @@ def rhophi_z(lib, rho, phi, z):
3535

3636

3737
def rhophi_theta(lib, rho, phi, theta):
38-
return lib.nan_to_num(rho / lib.tan(theta), 0.0)
38+
return lib.nan_to_num(rho / lib.tan(theta), nan=0.0)
3939

4040

4141
def rhophi_eta(lib, rho, phi, eta):

0 commit comments

Comments
 (0)