Example #1
0
 def from_dict(dict):
     return FinishedExperiment(
         backend_name=dict.get('backend_name', ''),
         backend_version=dict.get('backend_version', None),
         date=dateutil.parser.parse(dict['date']) if 'date' in dict else None,
         qobj=Qobj.from_dict(dict.get('qobj', {})),
         job_id=dict.get('job_id', ''),
         status=JobStatus[dict['job_status']] if 'job_status' in dict else JobStatus.INITIALIZING,
         results=[ExperimentResult.from_dict(d) for d in dict.get('results', [])],
         noise_model=NoiseModel.from_dict(dict['noise_model']) if 'noise_model' in dict and dict['noise_model'] is not None else None,
         external_id=dict.get('external_id', None),
         theta=dict.get('theta', np.arange(0, 2*np.pi, 0.1)),  # fixing a bug here.... argh!
         parameters=dict.get('parameters', [])
     )
Example #2
0
    def from_dict(cls, data):
        """Create a new ExperimentResultData object from a dictionary.

        Args:
            data (dict): A dictionary representing the Result to create. It
                         will be in the same format as output by
                         :meth:`to_dict`.
        Returns:
            Result: The ``Result`` object from the input dictionary.

        """

        in_data = copy.copy(data)
        in_data["results"] = [ExperimentResult.from_dict(x) for x in in_data.pop("results")]
        if "header" in in_data:
            in_data["header"] = QobjHeader.from_dict(in_data.pop("header"))
        return cls(**in_data)