easyvvuq.decoders.yaml

A Decoder that can be used to get information from a YAML file. Works identically to the JSON decoder. Look at the documentation of that class for more information

 1"""A Decoder that can be used to get information from a YAML file.
 2Works identically to the JSON decoder. Look at the documentation of that
 3class for more information
 4"""
 5
 6from easyvvuq.decoders.json import JSONDecoder
 7import logging
 8import yaml
 9
10__copyright__ = """
11
12    Copyright 2018 Robin A. Richardson, David W. Wright
13
14    This file is part of EasyVVUQ
15
16    EasyVVUQ is free software: you can redistribute it and/or modify
17    it under the terms of the Lesser GNU General Public License as published by
18    the Free Software Foundation, either version 3 of the License, or
19    (at your option) any later version.
20
21    EasyVVUQ is distributed in the hope that it will be useful,
22    but WITHOUT ANY WARRANTY; without even the implied warranty of
23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24    Lesser GNU General Public License for more details.
25
26    You should have received a copy of the Lesser GNU General Public License
27    along with this program.  If not, see <https://www.gnu.org/licenses/>.
28
29"""
30__license__ = "LGPL"
31
32
33logger = logging.Logger(__name__)
34
35
36class YAMLDecoder(JSONDecoder):
37    def _get_raw_data(self, out_path):
38        """Reads in data from a YAML file.
39
40        Parameters
41        ----------
42        out_path: str
43            File name of a YAML file produced by the simulation code.
44        """
45        with open(out_path) as fd:
46            return yaml.load(fd, yaml.SafeLoader)
logger = <Logger easyvvuq.decoders.yaml (NOTSET)>
class YAMLDecoder(easyvvuq.decoders.json.JSONDecoder):
37class YAMLDecoder(JSONDecoder):
38    def _get_raw_data(self, out_path):
39        """Reads in data from a YAML file.
40
41        Parameters
42        ----------
43        out_path: str
44            File name of a YAML file produced by the simulation code.
45        """
46        with open(out_path) as fd:
47            return yaml.load(fd, yaml.SafeLoader)