Skip to content

Commit

Permalink
post review test cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed May 4, 2018
1 parent 91abe95 commit 01ca025
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/test_psfCandidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
display = False


def makeEmptyCatalog(psfCandidateField=''):
def makeEmptyCatalog(psfCandidateField=None):
"""Return an empty catalog with a useful schema for psfCandidate testing.
Parameters
----------
psfCandidateField : `str`
psfCandidateField : `str` or None
The name of a flag field to add to the schema.
Returns
Expand All @@ -51,7 +51,7 @@ def makeEmptyCatalog(psfCandidateField=''):
"""
schema = afwTable.SourceTable.makeMinimalSchema()
lsst.afw.table.Point2DKey.addFields(schema, "centroid", "centroid", "pixels")
if psfCandidateField != '':
if psfCandidateField is not None:
schema.addField(psfCandidateField, type="Flag", doc="Is a psfCandidate?")
catalog = afwTable.SourceCatalog(schema)
catalog.defineCentroid('centroid')
Expand Down Expand Up @@ -97,6 +97,7 @@ def createFakeSource(x, y, catalog, exposure, threshold=0.1):
found = True
print(fp.getBBox())
break
# We cannot continue if the the created source wasn't found.
assert found, "Unable to find central peak in footprint: faulty test"

source.setFootprint(fp)
Expand Down Expand Up @@ -188,7 +189,15 @@ def testFaintNeighborMasking(self):
self.checkCandidateMasking([(self.x+5, self.y, 0.5)], threshold=0.9, pixelThreshold=1.0)


class MakePsfCandiatesTaskTest(lsst.utils.tests.TestCase):
class MakePsfCandidatesTaskTest(lsst.utils.tests.TestCase):
"""Test MakePsfCandidatesTask on a handful of fake sources.
Notes
-----
Does not test sources with NaN/Inf in their footprint. Also does not test
any properties of the resulting PsfCandidates: those are assumed to be tested
in ``CandidateMaskingTestCase`` above.
"""
def setUp(self):
self.psfCandidateField = "psfCandidate"
self.catalog = makeEmptyCatalog(self.psfCandidateField)
Expand All @@ -197,11 +206,11 @@ def setUp(self):
self.badIds = [1, ]
self.goodIds = [2, 3]
# x and y coordinate: keep these in sync with the above good/bad list.
self.xx = [0, 100, 200]
self.yy = [0, 100, 20]
self.xCoords = [0, 100, 200]
self.yCoords = [0, 100, 20]
self.exposure = afwImage.ExposureF(256, 256)
self.exposure.getMaskedImage().getVariance().set(0.01)
for x, y in zip(self.xx, self.yy):
for x, y in zip(self.xCoords, self.yCoords):
createFakeSource(x, y, self.catalog, self.exposure, 0.1)

self.makePsfCandidates = measAlg.MakePsfCandidatesTask()
Expand Down

0 comments on commit 01ca025

Please sign in to comment.