Skip to content

Commit

Permalink
End usage of FilterProperty, as per RFC-730.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Nov 9, 2020
1 parent a3f3dda commit 5d245ad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
13 changes: 0 additions & 13 deletions python/lsst/obs/base/formatters/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,4 @@ def _toBytes(self, inMemoryDataset: Any) -> bytes:
filter["name"] = inMemoryDataset.getName()
filter["aliases"] = inMemoryDataset.getAliases()

# This can fail if the filter is no longer available in the
# Singleton
try:
filterProperty = inMemoryDataset.getFilterProperty()
except LookupError:
pass
else:
properties = {}
properties["lambdaEff"] = filterProperty.getLambdaEff()
properties["lambdaMax"] = filterProperty.getLambdaMax()
properties["lambdaMin"] = filterProperty.getLambdaMin()
filter["properties"] = properties

return yaml.dump(filter).encode()
12 changes: 1 addition & 11 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,16 @@ def setUp(self):

def test_singleton(self):
self.filters1.defineFilters()
self.assertEqual(lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(), 123)
self.assertEqual(lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(), 456)
self.filters1.defineFilters() # this should not change anything
self.assertEqual(lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(), 123)
self.assertEqual(lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(), 456)
with self.assertRaises(RuntimeError):
self.filters2.defineFilters()
# the defined filters should be unchanged
self.assertEqual(lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(), 123)
self.assertEqual(lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(), 456)

def test_reset(self):
self.filters1.defineFilters()
with self.assertRaises(RuntimeError):
self.filters2.defineFilters()
self.filters1.reset()
# The new filters can be defiend and should replace the old ones.
# The new filters can be defined and should replace the old ones.
self.filters2.defineFilters()
self.assertEqual(lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(), 321)
self.assertEqual(lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(), 654)


class TestFilterDefinition(lsst.utils.tests.TestCase):
Expand Down

0 comments on commit 5d245ad

Please sign in to comment.