Skip to content

Commit

Permalink
Parametrize test for 'compute_distance2line'.
Browse files Browse the repository at this point in the history
  • Loading branch information
karandesai-96 committed Mar 31, 2016
1 parent 198e850 commit e2064f0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tardis/montecarlo/tests/test_cmontecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,21 @@ def test_compute_distance2boundary(packet_params, expected, packet, model):
np.testing.assert_almost_equal(obtained, expected)


def test_compute_distance2line():
distance_to_line = 7.792353908000001e+17
tests.test_compute_distance2line.restype = c_double
np.testing.assert_almost_equal(tests.test_compute_distance2line(),
distance_to_line)
@pytest.mark.parametrize(
['packet_params', 'expected_stat', 'expected_dist'],
[({'nu_line': 0.1, 'next_line_id': 0}, 0, 1.1694155862e+18),
({'nu_line': 0.2, 'next_line_id': 1}, 0, 7.796853907999999e+17),
({'nu_line': 0.5, 'next_line_id': 0}, 2, 0.0),
({'nu_line': 0.6, 'next_line_id': 1}, 2, 0.0)])
def test_compute_distance2line(packet_params, expected_stat, expected_dist, packet, model):
packet.nu_line = packet_params['nu_line']

cmontecarlo_methods.compute_distance2line.restype = c_uint
obtained_dist = c_double(0.0)
obtained_stat = cmontecarlo_methods.compute_distance2line(byref(packet), byref(model), byref(obtained_dist))

np.testing.assert_almost_equal(obtained_dist.value, expected_dist)
assert obtained_stat == expected_stat


def test_compute_distance2continuum():
Expand Down

0 comments on commit e2064f0

Please sign in to comment.