Skip to content

Commit

Permalink
Fix unit test and add tau_sc to output dict
Browse files Browse the repository at this point in the history
  • Loading branch information
telegraphic committed Jul 19, 2021
1 parent b6b75ee commit ee3765e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pygedm/ne2001_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ def dm_to_dist(l, b, dm, nu=1.0, full_output=False):
return 0.0 * u.pc, 0.0 * u.s
else:
d = ne21c.dm_to_dist(l_rad, b_rad, dm)
tau_sc = TAUISS(float(d['dist']), d['smtau'], nu=nu)

if not full_output:
tau_sc = TAUISS(float(d['dist']), d['smtau'], nu=nu)
return (float(d['dist']) * u.kpc).to('pc'), tau_sc * u.s
else:
d['tau_sc'] = tau_sc
return d


Expand All @@ -128,11 +129,12 @@ def dist_to_dm(l, b, dist, nu=1.0, full_output=False):
return 0.0 * u.pc / u.cm**3, 0.0 * u.s
else:
d = ne21c.dist_to_dm(l_rad, b_rad, dist)
tau_sc = TAUISS(float(dist), d['smtau'], nu=nu)

if not full_output:
tau_sc = TAUISS(float(dist), d['smtau'], nu=nu)
return float(d['dm']) * u.pc / u.cm**3, tau_sc * u.s
else:
d['tau_sc'] = tau_sc
return d

@run_from_pkgdir
Expand Down
3 changes: 2 additions & 1 deletion tests/test_basic_ne2001.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_dm_wrapper_b0353():
assert np.isclose(dist.to('kpc').value, 2.746, atol=0.01, rtol=0)
assert np.isclose(tau_sc.to('us').value, 6.57, atol=0.01, rtol=0)

test_full_output():
def test_full_output():
""" Make sure full_output arg works """
a = pygedm.ne2001_wrapper.dist_to_dm(0, 0, 0.1, full_output=True)
b = pygedm.ne2001_wrapper.dm_to_dist(0, 0, 10, full_output=True)
Expand All @@ -128,3 +128,4 @@ def test_dm_wrapper_b0353():
test_igm()
test_dm_wrapper()
test_dm_wrapper_b0353()
test_full_output()

0 comments on commit ee3765e

Please sign in to comment.