Skip to content

Commit

Permalink
Merge pull request #70 from pllim/stop-gap
Browse files Browse the repository at this point in the history
Raise exception when catalog gap detected
  • Loading branch information
pllim committed Feb 13, 2018
2 parents 604fa0d + 17d9c9a commit 992364c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions pysynphot/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ def _getSpectrum(self, parlist, basename):
os.path.join(basename,filename))
sp = spectrum.TabularSourceSpectrum(filename, fluxname=column)

totflux = sp.integrate()
if not N.isfinite(totflux) or totflux <= 0:
raise exceptions.ParameterOutOfBounds(
"Parameter '{0}' has no valid data.".format(parlist))

result = []
for member in parlist:
result.append(member)
Expand Down
26 changes: 19 additions & 7 deletions pysynphot/test/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ def test_flux(self):

@use_cdbs
@pytest.mark.parametrize(
('teff', 'z', 'logg'),
[(6440, 0, 10),
(6440, 0, -1),
(1.e6, 0, 4.3),
(100, 0, 4.3),
(6440, 2, 4.3),
(6440, -6, 4.3)])
('teff', 'z', 'logg'),
[(6440, 0, 10),
(6440, 0, -1),
(1.e6, 0, 4.3),
(100, 0, 4.3),
(6440, 2, 4.3),
(6440, -6, 4.3)])
def test_Icat_exceptions(teff, z, logg):
"""
Tests for changes related to Trac ticket #211.
Expand All @@ -82,6 +82,18 @@ def test_Icat_exceptions(teff, z, logg):
Icat('k93models', teff, z, logg)


@use_cdbs
def test_phoenix_gap():
"""
https://github.com/spacetelescope/pysynphot/issues/68
"""
Icat('phoenix', 2700, -1, 5.1) # OK
with pytest.raises(ParameterOutOfBounds):
Icat('phoenix', 2700, -0.5, 5.1)
with pytest.raises(ParameterOutOfBounds):
Icat('phoenix', 2700, -0.501, 5.1)


@use_cdbs
class TestCatalogCache(object):
"""
Expand Down

0 comments on commit 992364c

Please sign in to comment.