Skip to content

Commit

Permalink
Refactor test_bf_cross_section.
Browse files Browse the repository at this point in the history
  • Loading branch information
karandesai-96 committed Apr 29, 2016
1 parent 4f4a1e8 commit 1f099af
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tardis/montecarlo/tests/test_cmontecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,27 @@ def test_rpacket_doppler_factor(mu, r, inv_t_exp, expected, packet, model):
assert_almost_equal(obtained, expected)


@pytest.mark.parametrize(
['packet_params', 'expected'],
[({'nu': 0.1, 'mu': 0.3, 'r': 7.5e14}, 2.5010827921809502e+26),
({'nu': 0.2, 'mu': -.3, 'r': 7.7e14}, 3.123611229395459e+25)]
)
def test_bf_cross_section(packet_params, expected, packet, model):
packet.nu = packet_params['nu']
packet.mu = packet_params['mu']
packet.r = packet_params['r']

cmontecarlo_methods.rpacket_doppler_factor.restype = c_double
doppler_factor = cmontecarlo_methods.rpacket_doppler_factor(byref(packet), byref(model))
comov_nu = packet.nu * doppler_factor

cmontecarlo_methods.bf_cross_section.restype = c_double
obtained = cmontecarlo_methods.bf_cross_section(byref(model), c_int64(0),
c_double(comov_nu))

assert_almost_equal(obtained, expected)


@pytest.mark.parametrize(
['packet_params', 'expected_params'],
[({'mu': 0.3, 'r': 7.5e14},
Expand Down Expand Up @@ -340,11 +361,3 @@ def test_calculate_chi_bf():
@pytest.mark.xfail
def test_montecarlo_bound_free_scatter():
assert cmontecarlo_tests.test_montecarlo_bound_free_scatter() == 1


@pytest.mark.xfail
def test_bf_cross_section():
bf_cross_section = 0.0
cmontecarlo_tests.test_bf_cross_section.restype = c_double
assert_almost_equal(cmontecarlo_tests.test_bf_cross_section(),
bf_cross_section)

0 comments on commit 1f099af

Please sign in to comment.