Skip to content

Commit

Permalink
Merge pull request #134 from lsst/tickets/DM-16392
Browse files Browse the repository at this point in the history
DM-16392: Ensure ApCorr fields are added in a deterministic order.
  • Loading branch information
TallJimbo committed Nov 2, 2018
2 parents 48c959a + 2120646 commit 7e0e4ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python/lsst/meas/base/applyApCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(self, schema, **kwds):
if missingNameSet:
self.log.warn("Fields in ignoreList that are not in fluxCorrectList: %s",
sorted(list(missingNameSet)))
for name in apCorrNameSet - ignoreSet:
for name in sorted(list(apCorrNameSet - ignoreSet)):
if name + "_instFlux" not in schema:
# if a field in the registry is missing from the schema, silently ignore it.
continue
Expand Down
21 changes: 12 additions & 9 deletions tests/test_ApplyApCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ class ApplyApCorrTestCase(lsst.meas.base.tests.AlgorithmTestCase, lsst.utils.tes

def setUp(self):
schema = afwTable.SourceTable.makeMinimalSchema()
name = "test"
addApCorrName(name)
schema.addField(name + "_instFlux", type=np.float64)
schema.addField(name + "_instFluxErr", type=np.float64)
schema.addField(name + "_flag", type=np.float64)
schema.addField(name + "_Centroid_x", type=np.float64)
schema.addField(name + "_Centroid_y", type=np.float64)
schema.getAliasMap().set('slot_Centroid', name + '_Centroid')
names = ["test2", "test"]
for name in names:
addApCorrName(name)
schema.addField(name + "_instFlux", type=np.float64)
schema.addField(name + "_instFluxErr", type=np.float64)
schema.addField(name + "_flag", type=np.float64)
schema.addField(name + "_Centroid_x", type=np.float64)
schema.addField(name + "_Centroid_y", type=np.float64)
schema.getAliasMap().set('slot_Centroid', name + '_Centroid')
self.ap_corr_task = applyApCorr.ApplyApCorrTask(schema=schema)
self.name = name
self.name = name # just use 'test' prefix for most of the tests
self.schema = schema

def tearDown(self):
Expand All @@ -72,6 +73,8 @@ def testAddFields(self):
self.assertIn(self.name + "_apCorr", self.schema.getNames())
self.assertIn(self.name + "_apCorrErr", self.schema.getNames())
self.assertIn(self.name + "_flag_apCorr", self.schema.getNames())
self.assertLess(self.schema.find("test_apCorr").key.getOffset(),
self.schema.find("test2_apCorr").key.getOffset())

def testSuccessUnflagged(self):
# Check that the aperture correction flag is set to False if aperture correction was successfully run
Expand Down

0 comments on commit 7e0e4ff

Please sign in to comment.