Skip to content

Commit

Permalink
Adding a test for the wavelength range
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Mar 5, 2017
1 parent e015f6f commit 0b3adce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dust_extinction/dust_extinction.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def evaluate(in_x, Rv):
x = x_quant.value

# check that the wavenumbers are within the defined range
if np.any(x < 0.3):
if np.logical_or(np.any(x < 0.3),np.any(x > 10.0)):
raise ValueError('Input x outside of range defined for CCM89' \
+ ' [0.3 <= x <= 10, x has units 1/micron]')

Expand Down
8 changes: 8 additions & 0 deletions dust_extinction/tests/test_ccm89.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def test_invalid_Rv_input(Rv_invalid):
tmodel = CCM89(Rv=Rv_invalid)
assert exc.value.args[0] == 'parameter Rv must be between 2.0 and 6.0'

@pytest.mark.parametrize("x_invalid", [-1.0, 0.2, 10.1, 100.])
def test_invalid_wavenumbers(x_invalid):
tmodel = CCM89(Rv=3.1)
with pytest.raises(ValueError) as exc:
tmodel([x_invalid])
assert exc.value.args[0] == 'Input x outside of range defined for CCM89' \
+ ' [0.3 <= x <= 10, x has units 1/micron]'

@pytest.mark.parametrize("Rv", [2.0, 3.0, 3.1, 4.0, 5.0, 6.0])
def test_extinction_CCM89_values(Rv):
# testing wavenumbers
Expand Down

0 comments on commit 0b3adce

Please sign in to comment.