Skip to content

Commit 3d171a2

Browse files
committed
Added math tools tests
1 parent 5e5e7eb commit 3d171a2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pyx/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
from . import math_tools
33
from . import print_tools
44
from . import str_tools
5+
6+
from .__version__ import __version__

tests/test_math_tools.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,24 @@ def test_z_to_cMpc_zero():
1010
# Zero redshift should give zero distance
1111
dist = 0.0
1212
assert pyxcosmo.z_to_cMpc(0).value == dist
13+
14+
def test_z_to_cMpc_array():
15+
# Must return an array
16+
dist = np.array([0.0, 3395.905416665515])
17+
assert (pyxcosmo.z_to_cMpc(np.array([0, 1])).value == dist).all
18+
19+
def test_cMpc_to_z_float():
20+
z = 0.8479314667609102
21+
assert pyxcosmo.cMpc_to_z(3000) == z
22+
23+
def test_z_to_cMpc_zero():
24+
# Zero distance should give zero redshift
25+
z = 0.0
26+
assert pyxcosmo.cMpc_to_z(0) == z
27+
28+
def test_z_to_cMpc_array():
29+
# Must return an array
30+
z = np.array([0.0, 0.8479314667609102])
31+
assert (pyxcosmo.z_to_cMpc(np.array([0.0, 3000])).value == z).all
32+
33+

0 commit comments

Comments
 (0)