示例#1
0
    def load(filename):
        """
        Load an experiment from disk.

        Parameters
        ----------
        filename : str
            Path to a file generated by |Experiment.save|.

        Returns
        -------
        |Experiment|

        """
        with open(filename, 'r') as f:
            self = yaml.load(f)
        self.filename = filename
        return self
示例#2
0
    def load(filename):
        """
        Load an experiment from disk.

        Parameters
        ----------
        filename : str
            Path to a file generated by |Experiment.save|.

        Returns
        -------
        |Experiment|

        """
        with open(filename, 'r') as f:
            self = yaml.load(f)
        self.filename = filename
        return self
示例#3
0
    def from_yaml_file(cls, filename):
        """
        Construct an |Experiment| based on specification in a YAML file.
        Requires `PyYAML`_.

        Parameters
        ----------
        filename : str
            YAML file location.
            The YAML should specify a dictionary matching the specification of |Experiment.from_dict|.

        Returns
        -------
        |Experiment|

        """
        if not yaml:
            raise ImportError('PyYAML is not installed')
        with open(filename, 'r') as f:
            spec = yaml.load(f)
        return cls.from_dict(spec)
示例#4
0
    def from_yaml_file(cls, filename):
        """
        Construct an |Experiment| based on specification in a YAML file.
        Requires `PyYAML`_.

        Parameters
        ----------
        filename : str
            YAML file location.
            The YAML should specify a dictionary matching the specification of |Experiment.from_dict|.

        Returns
        -------
        |Experiment|

        """
        if not yaml:
            raise ImportError('PyYAML is not installed')
        with open(filename, 'r') as f:
            spec = yaml.load(f)
        return cls.from_dict(spec)
示例#5
0
def test_round_trip(data):
    cmp = yaml.load(yaml.dump(data)) == data
    if isinstance(cmp, np.ndarray):
        assert np.all(cmp)
    else:
        assert cmp
示例#6
0
def test_round_trip(data):
    cmp = yaml.load(yaml.dump(data)) == data
    if isinstance(cmp, np.ndarray):
        assert np.all(cmp)
    else:
        assert cmp