QdGateOutput#

class qudas.gate.output.QdGateOutput(results: Dict[str, QdGateOutputData] | None = None)[source]#

Bases: QdOutputBase

量子ゲート方式の計算結果を保持するアウトプットクラス。

1 ブロックにつき 1 つの結果辞書を保持し、複数ブロック分を results という大域辞書で管理する設計とする。

Example

>>> results = {
...     "blockA": {
...         "solution": {"x0": 1, "x1": 0},
...         "counts": {"00": 100, "11": 200},
...         "expectation_value": 0.5,
...         "shots": 300,
...         "device": "aer_simulator",
...     },
...     "blockB": {
...         "solution": {"x0": 0, "x1": 1},
...         "counts": {"00": 150, "11": 150},
...         "expectation_value": 0.2,
...         "shots": 300,
...         "device": "braket_ionq",
...     },
... }
>>> qd_out = QdGateOutput(results)
>>> qd_out.get_block_solution("blockA")
{'x0': 1, 'x1': 0}
classmethod from_sdk_format(sdk_obj: Any, target: str) QdGateOutput[source]#

外部 SDK 向けのフォーマットからインスタンスを生成します。

to_dict()[source]#

結果を辞書へシリアライズします。

to_sdk_format(target: str)[source]#

Backend 依存フォーマットへ変換 (ダミー実装)。

visualize()[source]#

結果を簡易可視化 (テキスト出力)。