Skip to content

Commit

Permalink
Pull tests out to be individual
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisherlevine committed Oct 25, 2022
1 parent a64f6db commit 7ff741c
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from lsst.summit.utils.utils import getExpPositionOffset, fluxesFromFootprints, detectObjectsInExp
from lsst.summit.utils.butlerUtils import makeDefaultLatissButler
from lsst.obs.lsst.translators.latiss import AUXTEL_LOCATION
from lsst.afw.detection import FootprintSet


class ExpSkyPositionOffsetTestCase(lsst.utils.tests.TestCase):
Expand Down Expand Up @@ -144,19 +143,32 @@ def test_fluxFromFootprint(self):

# check it can accept a footprintSet, and single and iterables of
# footprints
for obj in (footPrintSet, singleFootprint, twoFootprints):
fluxes = fluxesFromFootprints(obj, self.exp)
if isinstance(obj, FootprintSet):
expectedLength = len(footPrintSet.getFootprints())
self.assertEqual(len(fluxes), expectedLength) # always one flux per footprint

self.assertIsInstance(fluxes, Iterable)
self.assertIsInstance(fluxes[0], np.floating) # always returns floats
# check the footPrintSet
fluxes = fluxesFromFootprints(footPrintSet, self.exp)
expectedLength = len(footPrintSet.getFootprints())
self.assertEqual(len(fluxes), expectedLength) # always one flux per footprint
self.assertIsInstance(fluxes, Iterable)
self.assertIsInstance(fluxes[0], np.floating) # always returns floats

# check the singleFootprint
fluxes = fluxesFromFootprints(singleFootprint, self.exp)
expectedLength = 1
self.assertEqual(len(fluxes), expectedLength) # always one flux per footprint
self.assertIsInstance(fluxes, Iterable)
self.assertIsInstance(fluxes[0], np.floating) # always returns floats

# check the list of twoFootprints
fluxes = fluxesFromFootprints(twoFootprints, self.exp)
expectedLength = 2
self.assertEqual(len(fluxes), expectedLength) # always one flux per footprint
self.assertIsInstance(fluxes, Iterable)
self.assertIsInstance(fluxes[0], np.floating) # always returns floats

# ensure that subtracting the image median from fluxes leave image
# functionally unchanged
oldExpArray = copy.deepcopy(self.exp.image.array)
fluxes = fluxesFromFootprints(obj, self.exp, subtractImageMedian=True)
fluxes = fluxesFromFootprints(footPrintSet, self.exp, subtractImageMedian=True)
self.assertTrue(np.alltrue(np.equal(self.exp.image.array, oldExpArray)))


Expand Down

0 comments on commit 7ff741c

Please sign in to comment.