Source code for qiskit_experiments.framework.analysis_result_data
# This code is part of Qiskit.## (C) Copyright IBM 2021.## 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."""Helper dataclass for constructing analysis results."""importdataclassesimportloggingfromtypingimportOptional,Dict,Any,ListLOG=logging.getLogger(__name__)
[docs]@dataclasses.dataclassclassAnalysisResultData:"""Dataclass for experiment analysis results"""# TODO: move stderr and unit into custom value classname:strvalue:Anychisq:Optional[float]=Nonequality:Optional[str]=Noneextra:Dict[str,Any]=dataclasses.field(default_factory=dict,hash=False,compare=False)device_components:List=dataclasses.field(default_factory=list)def__str__(self):out=f"{self.name}:"out+=f"\n- value:{self.value}"ifself.chisqisnotNone:out+=f"\n- chisq: {self.chisq}"ifself.qualityisnotNone:out+=f"\n- quality: {self.quality}"ifself.extra:out+=f"\n- extra: <{len(self.extra)} items>"ifself.device_components:out+=f"\n- device_components: {[str(i)foriinself.device_components]}"returnoutdef__iter__(self):"""Return iterator of data fields (attr, value)"""returniter((field.name,getattr(self,field.name))forfieldindataclasses.fields(self))