From 6a8d48ff22e7551445433ff0cf1359f450cced90 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Thu, 17 Feb 2022 10:26:16 +0000 Subject: [PATCH] [pytket-qiskit] Remove `characterisation` property of backends (#297) --- modules/pytket-qiskit/_metadata.py | 2 +- modules/pytket-qiskit/docs/changelog.rst | 6 ++++++ .../pytket/extensions/qiskit/backends/aer.py | 8 +------- .../pytket/extensions/qiskit/backends/ibm.py | 4 ---- .../pytket/extensions/qiskit/backends/ibmq_emulator.py | 5 ----- modules/pytket-qiskit/tests/backend_test.py | 4 ++-- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/modules/pytket-qiskit/_metadata.py b/modules/pytket-qiskit/_metadata.py index 7e595163..65b0e7c5 100644 --- a/modules/pytket-qiskit/_metadata.py +++ b/modules/pytket-qiskit/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.22.2" +__extension_version__ = "0.23.0" __extension_name__ = "pytket-qiskit" diff --git a/modules/pytket-qiskit/docs/changelog.rst b/modules/pytket-qiskit/docs/changelog.rst index ed3829d5..44fd8c93 100644 --- a/modules/pytket-qiskit/docs/changelog.rst +++ b/modules/pytket-qiskit/docs/changelog.rst @@ -1,6 +1,12 @@ Changelog ~~~~~~~~~ +0.23.0 (unreleased) +------------------- + +* Removed ``characterisation`` property of backends. (Use `backend_info` + instead.) + 0.22.2 (February 2022) ---------------------- diff --git a/modules/pytket-qiskit/pytket/extensions/qiskit/backends/aer.py b/modules/pytket-qiskit/pytket/extensions/qiskit/backends/aer.py index 57a82e4b..3d810905 100644 --- a/modules/pytket-qiskit/pytket/extensions/qiskit/backends/aer.py +++ b/modules/pytket-qiskit/pytket/extensions/qiskit/backends/aer.py @@ -16,7 +16,6 @@ from collections import defaultdict from logging import warning from typing import ( - Any, Callable, Dict, List, @@ -138,11 +137,6 @@ def __init__(self, backend_name: str): def _result_id_type(self) -> _ResultIdTuple: return (str, int) - @property - def characterisation(self) -> Optional[Dict[str, Any]]: - char = self._backend_info.get_misc("characterisation") - return cast(Dict[str, Any], char) if char else None - @property def backend_info(self) -> BackendInfo: return self._backend_info @@ -493,7 +487,7 @@ def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass: else: passlist.append(FullPeepholeOptimise()) arch = self._backend_info.architecture - if arch.coupling and self.characterisation: + if arch.coupling and self._backend_info.get_misc("characterisation"): # architecture is non-trivial passlist.append( CXMappingPass( diff --git a/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibm.py b/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibm.py index 50bc6c30..07764c26 100644 --- a/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibm.py +++ b/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibm.py @@ -307,10 +307,6 @@ def _get_provider( return provider - @property - def characterisation(self) -> Dict[str, Any]: - return cast(Dict[str, Any], self._backend_info.get_misc("characterisation")) - @property def backend_info(self) -> BackendInfo: return self._backend_info diff --git a/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibmq_emulator.py b/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibmq_emulator.py index 2768ec3a..b1300312 100644 --- a/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibmq_emulator.py +++ b/modules/pytket-qiskit/pytket/extensions/qiskit/backends/ibmq_emulator.py @@ -15,7 +15,6 @@ import json from typing import ( cast, - Any, Dict, Optional, List, @@ -92,10 +91,6 @@ def __init__( # cache of results keyed by job id and circuit index self._ibm_res_cache: Dict[Tuple[str, int], ExperimentResult] = dict() - @property - def characterisation(self) -> Optional[Dict[str, Any]]: - return self._ibmq.characterisation - @property def backend_info(self) -> BackendInfo: return self._ibmq.backend_info diff --git a/modules/pytket-qiskit/tests/backend_test.py b/modules/pytket-qiskit/tests/backend_test.py index e1eaf7b8..6b2d035b 100644 --- a/modules/pytket-qiskit/tests/backend_test.py +++ b/modules/pytket-qiskit/tests/backend_test.py @@ -207,7 +207,7 @@ def test_process_characterisation() -> None: def test_process_characterisation_no_noise_model() -> None: my_noise_model = NoiseModel() back = AerBackend(my_noise_model) - assert back.characterisation is None + assert back.backend_info.get_misc("characterisation") is None c = Circuit(4).CX(0, 1).H(2).CX(2, 1).H(3).CX(0, 3).H(1).X(0) c = back.get_compiled_circuit(c) @@ -303,7 +303,7 @@ def test_process_characterisation_complete_noise_model() -> None: ) back = AerBackend(my_noise_model) - char = cast(Dict[str, Any], back.characterisation) + char = cast(Dict[str, Any], back.backend_info.get_misc("characterisation")) node_errors = cast(Dict, back.backend_info.all_node_gate_errors) link_errors = cast(Dict, back.backend_info.all_edge_gate_errors)