Skip to content

Commit

Permalink
Add ability to forward fields while reading exposure summary stats.
Browse files Browse the repository at this point in the history
This specifically lets "decl" be forwarded to "dec".
  • Loading branch information
erykoff committed Sep 11, 2023
1 parent 3f63d3d commit 5aa57cb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/lsst/afw/image/_exposureSummaryStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,19 @@ def _write(self):
@staticmethod
def _read(bytes):
yamlDict = yaml.load(bytes, Loader=yaml.SafeLoader)

# Special list of fields to forward to new names.
forwardFieldDict = {"decl": "dec"}

# For forwards compatibility, filter out any fields that are
# not defined in the dataclass.
droppedFields = []
for _field in list(yamlDict.keys()):
if _field not in ExposureSummaryStats.__dataclass_fields__:
droppedFields.append(_field)
if _field in forwardFieldDict and forwardFieldDict[_field] not in yamlDict:
yamlDict[forwardFieldDict[_field]] = yamlDict[_field]
else:
droppedFields.append(_field)
yamlDict.pop(_field)
if len(droppedFields) > 0:
droppedFieldString = ", ".join([str(f) for f in droppedFields])
Expand Down

0 comments on commit 5aa57cb

Please sign in to comment.