Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make libyaml optional #304

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions openmmtools/storage/iodrivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
import netCDF4 as nc
from sys import getsizeof

try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper

from simtk import unit

from ..utils import typename, quantity_from_string
Expand Down Expand Up @@ -1535,7 +1540,7 @@ def storage_type(self):
# NETCDF DICT YAML HANDLERS
# =============================================================================

class _DictYamlLoader(yaml.CLoader):
class _DictYamlLoader(Loader):
"""PyYAML Loader that recognized !Quantity nodes, converts YAML output -> Python type"""
def __init__(self, *args, **kwargs):
super(_DictYamlLoader, self).__init__(*args, **kwargs)
Expand All @@ -1549,7 +1554,7 @@ def quantity_constructor(loader, node):
return data_value * data_unit


class _DictYamlDumper(yaml.CDumper):
class _DictYamlDumper(Dumper):
"""PyYAML Dumper that convert from Python -> YAML output"""
def __init__(self, *args, **kwargs):
super(_DictYamlDumper, self).__init__(*args, **kwargs)
Expand Down