Skip to content

Commit

Permalink
Merge pull request #352 from lsst/tickets/DM-28577
Browse files Browse the repository at this point in the history
DM-28577: Surpress Filter warnings in FilterDefinitions
  • Loading branch information
parejkoj authored Feb 2, 2021
2 parents 9468cfe + ee116b9 commit f694b73
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions python/lsst/obs/base/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import dataclasses
import collections.abc
import warnings

import numpy as np

Expand Down Expand Up @@ -81,9 +82,12 @@ def defineFilters(self):
``defineFilters``.
"""
if self._defined is None:
self.reset()
for filter in self._filters:
filter.defineFilter()
with warnings.catch_warnings():
# surpress Filter warnings; we already know this is deprecated
warnings.simplefilter('ignore', category=FutureWarning)
self.reset()
for filter in self._filters:
filter.defineFilter()
FilterDefinitionCollection._defined = self
elif self._defined is self:
# noop: we've already defined these filters, so do nothing
Expand All @@ -97,7 +101,10 @@ def reset(cls):
"""Reset the afw Filter definitions and clear the `defined` singleton.
Use this in unittests that define different filters.
"""
lsst.afw.image.utils.resetFilters()
with warnings.catch_warnings():
# surpress Filter warnings; we already know this is deprecated
warnings.simplefilter('ignore', category=FutureWarning)
lsst.afw.image.utils.resetFilters()
cls._defined = None

def findAll(self, name):
Expand Down Expand Up @@ -224,11 +231,14 @@ def defineFilter(self):
if self.afw_name is not None:
if self.band is not None:
aliases.add(self.band)
lsst.afw.image.utils.defineFilter(name,
lambdaEff=self.lambdaEff,
lambdaMin=self.lambdaMin,
lambdaMax=self.lambdaMax,
alias=sorted(aliases))
with warnings.catch_warnings():
# surpress Filter warnings; we already know this is deprecated
warnings.simplefilter('ignore', category=FutureWarning)
lsst.afw.image.utils.defineFilter(name,
lambdaEff=self.lambdaEff,
lambdaMin=self.lambdaMin,
lambdaMax=self.lambdaMax,
alias=sorted(aliases))

def makeFilterLabel(self):
"""Create a complete FilterLabel for this filter.
Expand Down

0 comments on commit f694b73

Please sign in to comment.