Skip to content

Commit

Permalink
io/util.py: Change the way YAMLLoader identifies floats
Browse files Browse the repository at this point in the history
Instead of using yaml's faulty regular expression to implicitly
resolve floats, actually try to convert the property to
float and see if that succeeds.

With this change values like 5e3 will successfully get
parsed as floats, while pyyaml required a format of 5.e+3

While this is more reliable, it is also much slower.
  • Loading branch information
ftsamis committed May 25, 2016
1 parent 780a459 commit 5a7fb6a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tardis/io/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def construct_quantity(self, 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))


def parse_abundance_dict_to_dataframe(abundance_dict):
Expand Down

0 comments on commit 5a7fb6a

Please sign in to comment.