Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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