Skip to content

Commit

Permalink
io/util.py (YAMLLoader): Use OrderedDict to store loaded YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
ftsamis committed May 26, 2016
1 parent 6b100e5 commit 318d1d5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tardis/io/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pandas as pd
import numpy as np
import collections
from collections import OrderedDict
import yaml
import copy
from astropy import constants, units as u
Expand Down Expand Up @@ -117,11 +118,16 @@ def construct_quantity(self, node):
data = self.construct_scalar(node)
return quantity_from_str(data)

def mapping_constructor(self, node):
return OrderedDict(self.construct_pairs(node))

YAMLLoader.add_constructor(u'!quantity', YAMLLoader.construct_quantity)
YAMLLoader.add_implicit_resolver(u'!quantity',
MockRegexPattern(quantity_from_str))
YAMLLoader.add_implicit_resolver(u'tag:yaml.org,2002:float',
MockRegexPattern(float))
YAMLLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
YAMLLoader.mapping_constructor)


def parse_abundance_dict_to_dataframe(abundance_dict):
Expand Down

0 comments on commit 318d1d5

Please sign in to comment.