def testGetPropertyListFromFitsChanUnsupportedTypes(self): fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") fc.setFitsCF("ACOMPLEX", complex(1, 1)) with self.assertRaises(lsst.pex.exceptions.TypeError): getPropertyListFromFitsChan(fc) fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") fc.setFitsU("UNDEFVAL") with self.assertRaises(lsst.pex.exceptions.TypeError): getPropertyListFromFitsChan(fc)
def testGetPropertyListFromFitsChanWithComments(self): fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") # add one card for each supported type, with a comment continueVal = "This is a continue card" floatVal = 1.5 intVal = 99 logicalVal = True stringVal = "This is a string" fc.setFitsCN("ACONT", continueVal, "Comment for ACONT") fc.setFitsF("AFLOAT", floatVal, "Comment for AFLOAT") fc.setFitsI("ANINT", intVal, "Comment for ANINT") fc.setFitsL("ALOGICAL", logicalVal, "Comment for ALOGICAL") fc.setFitsS("ASTRING", stringVal, "Comment for ASTRING") fc.setFitsCM( "a comment, which will be ignored by getPropertyListFromFitsChan") fc.setFitsU("ANUNDEF", "Comment for ANUNDEF") expectedNames = [ "ACONT", "AFLOAT", "ANINT", "ALOGICAL", "ASTRING", "ANUNDEF" ] self.assertEqual(fc.nCard, 7) metadata = getPropertyListFromFitsChan(fc) self.assertEqual(metadata.getOrderedNames(), expectedNames) self.assertEqual(metadata.getScalar("ACONT"), continueVal) self.assertAlmostEqual(metadata.getScalar("AFLOAT"), floatVal) self.assertEqual(metadata.getScalar("ANINT"), intVal) self.assertEqual(metadata.getScalar("ALOGICAL"), logicalVal) self.assertEqual(metadata.getScalar("ASTRING"), stringVal) self.assertEqual(metadata.getScalar("ACONT"), continueVal) self.assertIsNone(metadata.getScalar("ANUNDEF")) for name in expectedNames: self.assertEqual(metadata.getComment(name), "Comment for %s" % (name, )) # complex values are not supported by PropertyList fc.setFitsCF("UNSUPP", complex(1, 0)) badCard = fc.getCard() with self.assertRaises(lsst.pex.exceptions.TypeError): getPropertyListFromFitsChan(fc) fc.setCard(badCard) fc.clearCard() fc.findFits("UNSUPP", inc=False) fc.delFits() metadata = getPropertyListFromFitsChan(fc) self.assertEqual(metadata.getOrderedNames(), expectedNames)
def testGetFitsCardsNoComments(self): fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") # add one card for each supported type, with a comment continueVal = "This is a continue card" floatVal = 1.5 intVal = 99 logicalVal = True stringVal = "This is a string" fc.setFitsCN("ACONT", continueVal) fc.setFitsF("AFLOAT", floatVal) fc.setFitsI("ANINT", intVal) fc.setFitsL("ALOGICAL", logicalVal) fc.setFitsS("ASTRING", stringVal) fc.setFitsCM("a comment, which will be ignored by getPropertyListFromFitsChan") self.assertEqual(fc.nCard, 6) metadata = getPropertyListFromFitsChan(fc) self.assertEqual(metadata.getOrderedNames(), ["ACONT", "AFLOAT", "ANINT", "ALOGICAL", "ASTRING"]) self.assertEqual(metadata.get("ACONT"), continueVal) self.assertAlmostEqual(metadata.get("AFLOAT"), floatVal) self.assertEqual(metadata.get("ANINT"), intVal) self.assertEqual(metadata.get("ALOGICAL"), logicalVal) self.assertEqual(metadata.get("ASTRING"), stringVal) self.assertEqual(metadata.get("ACONT"), continueVal)
def testGetFitsCardsNoComments(self): fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") # add one card for each supported type, with a comment continueVal = "This is a continue card" floatVal = 1.5 intVal = 99 logicalVal = True stringVal = "This is a string" fc.setFitsCN("ACONT", continueVal) fc.setFitsF("AFLOAT", floatVal) fc.setFitsI("ANINT", intVal) fc.setFitsL("ALOGICAL", logicalVal) fc.setFitsS("ASTRING", stringVal) fc.setFitsCM("a comment, which will be ignored by getPropertyListFromFitsChan") self.assertEqual(fc.nCard, 6) metadata = getPropertyListFromFitsChan(fc) self.assertEqual(metadata.getOrderedNames(), ["ACONT", "AFLOAT", "ANINT", "ALOGICAL", "ASTRING"]) self.assertEqual(metadata.getScalar("ACONT"), continueVal) self.assertAlmostEqual(metadata.getScalar("AFLOAT"), floatVal) self.assertEqual(metadata.getScalar("ANINT"), intVal) self.assertEqual(metadata.getScalar("ALOGICAL"), logicalVal) self.assertEqual(metadata.getScalar("ASTRING"), stringVal) self.assertEqual(metadata.getScalar("ACONT"), continueVal)
def testGetPropertyListFromFitsChanWithComments(self): fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") # add one card for each supported type, with a comment continueVal = "This is a continue card" floatVal = 1.5 intVal = 99 logicalVal = True stringVal = "This is a string" fc.setFitsCN("ACONT", continueVal, "Comment for ACONT") fc.setFitsF("AFLOAT", floatVal, "Comment for AFLOAT") fc.setFitsI("ANINT", intVal, "Comment for ANINT") fc.setFitsL("ALOGICAL", logicalVal, "Comment for ALOGICAL") fc.setFitsS("ASTRING", stringVal, "Comment for ASTRING") fc.setFitsCM("a comment, which will be ignored by getPropertyListFromFitsChan") fc.setFitsU("ANUNDEF", "Comment for ANUNDEF") expectedNames = ["ACONT", "AFLOAT", "ANINT", "ALOGICAL", "ASTRING", "ANUNDEF"] self.assertEqual(fc.nCard, 7) metadata = getPropertyListFromFitsChan(fc) self.assertEqual(metadata.getOrderedNames(), expectedNames) self.assertEqual(metadata.getScalar("ACONT"), continueVal) self.assertAlmostEqual(metadata.getScalar("AFLOAT"), floatVal) self.assertEqual(metadata.getScalar("ANINT"), intVal) self.assertEqual(metadata.getScalar("ALOGICAL"), logicalVal) self.assertEqual(metadata.getScalar("ASTRING"), stringVal) self.assertEqual(metadata.getScalar("ACONT"), continueVal) self.assertIsNone(metadata.getScalar("ANUNDEF")) for name in expectedNames: self.assertEqual(metadata.getComment(name), "Comment for %s" % (name,)) # complex values are not supported by PropertyList fc.setFitsCF("UNSUPP", complex(1, 0)) badCard = fc.getCard() with self.assertRaises(lsst.pex.exceptions.TypeError): getPropertyListFromFitsChan(fc) fc.setCard(badCard) fc.clearCard() fc.findFits("UNSUPP", inc=False) fc.delFits() metadata = getPropertyListFromFitsChan(fc) self.assertEqual(metadata.getOrderedNames(), expectedNames)
def testGetPropertyListFromFitsChanUnsupportedTypes(self): fc = ast.FitsChan(ast.StringStream()) self.assertEqual(fc.className, "FitsChan") fc.setFitsCF("ACOMPLEX", complex(1, 1)) with self.assertRaises(lsst.pex.exceptions.TypeError): getPropertyListFromFitsChan(fc)