Source code for qiskit_experiments.database_service.db_analysis_result_data
# This code is part of Qiskit.## (C) Copyright IBM 2022.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Dataclass for analysis result data in the database"""importcopyimportuuidfromdataclassesimportdataclass,fieldfromtypingimportAnyfromdatetimeimportdatetimefrom.constantsimportResultQualityfrom.device_componentimportDeviceComponent
[docs]@dataclassclassDbAnalysisResultData:"""Dataclass for experiment analysis results in the database. .. note:: The documentation does not currently render all the fields of this dataclass. .. note:: This class is named DbAnalysisResultData to avoid confusion with the :class:`~qiskit_experiments.framework.AnalysisResult` class. """result_id:str|None=field(default_factory=lambda:str(uuid.uuid4()))experiment_id:str|None=Noneresult_type:str|None=Noneresult_data:dict[str,Any]|None=field(default_factory=dict)device_components:list[str|DeviceComponent]|str|DeviceComponent|None=field(default_factory=list)quality:ResultQuality|None=ResultQuality.UNKNOWNverified:bool|None=Falsetags:list[str]|None=field(default_factory=list)backend_name:str|None=Nonecreation_datetime:datetime|None=Noneupdated_datetime:datetime|None=Nonechisq:float|None=Nonedef__str__(self):ret=f"Result {self.result_type}"ret+=f"\nResult ID: {self.result_id}"ret+=f"\nExperiment ID: {self.experiment_id}"ret+=f"\nBackend: {self.backend_name}"ret+=f"\nQuality: {self.quality}"ret+=f"\nVerified: {self.verified}"ret+=f"\nDevice components: {self.device_components}"ret+=f"\nData: {self.result_data}"ifself.chisq:ret+=f"\nChi Square: {self.chisq}"ifself.tags:ret+=f"\nTags: {self.tags}"ifself.creation_datetime:ret+=f"\nCreated at: {self.creation_datetime}"ifself.updated_datetime:ret+=f"\nUpdated at: {self.updated_datetime}"returnret
[docs]defcopy(self):"""Creates a deep copy of the data"""returnDbAnalysisResultData(result_id=self.result_id,experiment_id=self.experiment_id,result_type=self.result_type,result_data=copy.deepcopy(self.result_data),device_components=copy.copy(self.device_components),quality=self.quality,verified=self.verified,tags=copy.copy(self.tags),backend_name=self.backend_name,creation_datetime=self.creation_datetime,updated_datetime=self.updated_datetime,chisq=self.chisq,)