-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove double valued energies at edges and adding test for interpolation
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
|
||
from numpy.testing import assert_allclose | ||
|
||
import astropy.units as u | ||
|
||
from roentgen.absorption.material import MassAttenuationCoefficient | ||
|
||
|
||
def test_interpolate_matches_at_data(): | ||
for this_element in ['Te', 'Si', 'Ge', 'cdte']: | ||
te = MassAttenuationCoefficient(this_element) | ||
assert_allclose(te.data, te.func(te.energy)) | ||
|
||
# now change one point and make sure it no longer works | ||
te.energy[0] = 10 * u.keV | ||
with pytest.raises(AssertionError): | ||
assert_allclose(te.data, te.func(te.energy)) |
3995ed1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the numpy interp1d not work as is? If it did, I think that's a better way to handle this than to make a discreet shift in energy at the bottom of the edge.