Skip to content

Commit aa790f6

Browse files
authored
Generatorify stringify_dict function (#563)
2 parents 5dcb264 + b8fcfbe commit aa790f6

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

scopesim/detector/detector.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def reset(self):
4141
@property
4242
def hdu(self):
4343
"""Return internal HDU."""
44-
new_meta = stringify_dict(self.meta)
45-
self._hdu.header.update(new_meta)
44+
self._hdu.header.update(stringify_dict(self.meta))
4645

4746
pixel_scale = from_currsys("!INST.pixel_scale", self.cmds)
4847
plate_scale = from_currsys("!INST.plate_scale", self.cmds)

scopesim/utils.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -499,14 +499,13 @@ def has_needed_keywords(header, suffix=""):
499499
return all(key in header.keys() for key in keys)
500500

501501

502-
def stringify_dict(dic, ignore_types=(str, int, float)):
502+
def stringify_dict(dic, ignore_types=(str, int, float, bool)):
503503
"""Turn a dict entries into strings for addition to FITS headers."""
504-
dic_new = deepcopy(dic)
505-
for key in dic_new:
506-
if not isinstance(dic_new[key], ignore_types):
507-
dic_new[key] = str(dic_new[key])
508-
509-
return dic_new
504+
for key, value in dic.items():
505+
if isinstance(value, ignore_types):
506+
yield key, value
507+
else:
508+
yield key, str(value)
510509

511510

512511
def from_currsys(item, cmds=None):

0 commit comments

Comments
 (0)