From 9c9b01eebe9bf401b40b41694863015d43202caa Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 11 Sep 2023 16:00:51 -0700 Subject: [PATCH] Add tests for exposure summary stats column forwarding. --- tests/test_exposure.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_exposure.py b/tests/test_exposure.py index 46e7358c0..15f2aea88 100644 --- a/tests/test_exposure.py +++ b/tests/test_exposure.py @@ -26,6 +26,7 @@ import dataclasses import os.path import unittest +import warnings import numpy as np from numpy.testing import assert_allclose @@ -1158,6 +1159,31 @@ def testExposureSummaryExtraComponents(self): self.assertEqual(summaryStats.ra, testDict['ra']) self.assertEqual(summaryStats.dec, testDict['dec']) + def testExposureSummaryForwardComponents(self): + """Test that we can forward extra components (e.g. decl->dec). + """ + testDict = {'ra': 10.0, + 'decl': 10.0} + bytes = yaml.dump(testDict, encoding='utf-8') + # Cleanly forwarded fields must not result in a warning. + with warnings.catch_warnings(): + warnings.simplefilter("error") + summaryStats = lsst.afw.image.ExposureSummaryStats._read(bytes) + + self.assertEqual(summaryStats.ra, testDict['ra']) + self.assertEqual(summaryStats.dec, testDict['decl']) + + # And check if there are both listed, it should use the new dec value. + testDict = {'ra': 10.0, + 'dec': 5.0, + 'decl': 10.0} + bytes = yaml.dump(testDict, encoding='utf-8') + with self.assertWarns(FutureWarning): + summaryStats = lsst.afw.image.ExposureSummaryStats._read(bytes) + + self.assertEqual(summaryStats.ra, testDict['ra']) + self.assertEqual(summaryStats.dec, testDict['dec']) + def testExposureSummarySchema(self): """Test that we can make a schema for an exposure summary and populate records with that schema.