Skip to content

Commit

Permalink
Merge pull request #657 from ftsamis/require-pyyaml-3.12
Browse files Browse the repository at this point in the history
Require pyyaml 3.12
  • Loading branch information
wkerzendorf authored Sep 22, 2016
2 parents 4e386f6 + 980cda4 commit 8029951
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 36 deletions.
37 changes: 2 additions & 35 deletions tardis/io/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import collections
from collections import OrderedDict
import yaml
import copy
from astropy import constants, units as u
from tardis.util import element_symbol2atomic_number

Expand Down Expand Up @@ -66,38 +65,6 @@ class YAMLLoader(yaml.Loader):
A custom YAML loader containing all the constructors required
to properly parse the tardis configuration.
"""
@classmethod
def add_implicit_resolver(cls, tag, regexp, first=None):
"""
Parameters
----------
tag:
The YAML tag to implicitly apply to any YAML scalar that matches `regexp`
regexp:
The regular expression to match YAML scalars against `tag`
Notes
-----
This classmethod is a monkey-patch for a copy() related bug
in the original class method which affects this yaml.Loader subclass.
This class method is to be removed when this bug gets fixed upstream.
https://bitbucket.org/xi/pyyaml/issues/57/add_implicit_resolver-on-a-subclass-may
"""
if 'yaml_implicit_resolvers' not in cls.__dict__:
yaml_implicit_resolvers = {}
for k, v in cls.yaml_implicit_resolvers.items():
yaml_implicit_resolvers[k] = copy.copy(v)
cls.yaml_implicit_resolvers = yaml_implicit_resolvers
if first is None:
first = [None]
for ch in first:
cls.yaml_implicit_resolvers.setdefault(ch, []).append((tag, regexp))

def construct_quantity(self, node):
"""
Expand All @@ -124,9 +91,9 @@ def mapping_constructor(self, node):

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

Expand Down
3 changes: 2 additions & 1 deletion tardis_env27.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ dependencies:
- h5py=2.5
- matplotlib=1.4.3
- astropy=1.1.2
- PyYAML=3.11
- numexpr=2.4.4
- Cython=0.21
- networkx=1.10
- pytest=2.9.1
- pyyaml=3.12
- jsonschema=2.5.1


Expand All @@ -28,6 +28,7 @@ dependencies:
- requests=2.9.1
- docopt=0.6.2
- pytest-cov=2.2.1

- pip:
- nbsphinx
- sphinx_bootstrap_theme
Expand Down

0 comments on commit 8029951

Please sign in to comment.