panoptes / panoptes-utils

A set of Astronomical utility functions. PANOPTES style. :hammer_and_wrench: :telescope: :stars:
https://panoptes-utils.readthedocs.io
MIT License
4 stars 9 forks source link

panoptes.utils.serializers.from_yaml fails to parse astropy quantities #303

Open fergusL opened 1 year ago

fergusL commented 1 year ago

The from_yaml function is intended to be able to parse a yaml config for astropy quantities, however this fails as when the yaml object is created here, it is created as a ruamel.yaml.comments.CommentedSeq object. When this object is parsed by the deserialize_all_objects function, it checks if the object is a dict or OrderedDict instance before attempting to parse any entries intended as astropy quantities. As the object is not an instance of either type, it will never be parsed.

In [1]: from panoptes.utils.serializers import from_yaml

In [2]: with open('./fields.yaml', 'r') as f:
    ...:   c = from_yaml(f.read())
    ...: 

In [3]: type(c)
Out[3]: ruamel.yaml.comments.CommentedSeq

In [4]: isinstance(c, (dict, OrderedDict))
Out[4]: False