From 235f3b427e46fc48864acc0a0af9551bdf5347af Mon Sep 17 00:00:00 2001 From: ElStabilini Date: Thu, 28 Nov 2024 12:26:48 +0400 Subject: [PATCH] change from GlobalBackends() call to get_backend() call for compatibility with qibo v0.2.13 --- src/qibocal/protocols/randomized_benchmarking/utils.py | 4 ++-- src/qibocal/protocols/readout_mitigation_matrix.py | 4 ++-- src/qibocal/protocols/state_tomography.py | 4 ++-- src/qibocal/protocols/two_qubit_state_tomography.py | 4 ++-- tests/test_task_options.py | 4 ++-- tests/test_transpile.py | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/qibocal/protocols/randomized_benchmarking/utils.py b/src/qibocal/protocols/randomized_benchmarking/utils.py index a10188171..326c0fdf5 100644 --- a/src/qibocal/protocols/randomized_benchmarking/utils.py +++ b/src/qibocal/protocols/randomized_benchmarking/utils.py @@ -7,7 +7,7 @@ import numpy as np import numpy.typing as npt from qibo import gates -from qibo.backends import GlobalBackend +from qibo.backends import get_backend from qibo.config import raise_error from qibo.models import Circuit @@ -351,7 +351,7 @@ def setup( tuple: A tuple containing the experiment data, noise model, and backend. """ - backend = GlobalBackend() + backend = get_backend() backend.platform = platform # For simulations, a noise model can be added. noise_model = None diff --git a/src/qibocal/protocols/readout_mitigation_matrix.py b/src/qibocal/protocols/readout_mitigation_matrix.py index 780d08d7d..4272017f6 100644 --- a/src/qibocal/protocols/readout_mitigation_matrix.py +++ b/src/qibocal/protocols/readout_mitigation_matrix.py @@ -5,7 +5,7 @@ import numpy.typing as npt import plotly.express as px from qibo import gates -from qibo.backends import GlobalBackend +from qibo.backends import get_backend from qibo.models import Circuit from qibolab import PulseSequence from scipy.sparse import lil_matrix @@ -115,7 +115,7 @@ def _acquisition( data = ReadoutMitigationMatrixData( nshots=params.nshots, qubit_list=[list(qq) for qq in targets] ) - backend = GlobalBackend() + backend = get_backend() backend.platform = platform transpiler = dummy_transpiler(backend) diff --git a/src/qibocal/protocols/state_tomography.py b/src/qibocal/protocols/state_tomography.py index 7089bfeb2..be6d8aa6a 100644 --- a/src/qibocal/protocols/state_tomography.py +++ b/src/qibocal/protocols/state_tomography.py @@ -8,7 +8,7 @@ import plotly.graph_objects as go from plotly.subplots import make_subplots from qibo import Circuit, gates -from qibo.backends import GlobalBackend, NumpyBackend, matrices +from qibo.backends import NumpyBackend, get_backend, matrices from qibo.quantum_info import fidelity, partial_trace from qibocal.auto.operation import DATAFILE, Data, Parameters, QubitId, Results, Routine @@ -103,7 +103,7 @@ def _acquisition( if params.circuit is None: params.circuit = Circuit(len(targets)) - backend = GlobalBackend() + backend = get_backend() backend.platform = platform transpiler = dummy_transpiler(backend) diff --git a/src/qibocal/protocols/two_qubit_state_tomography.py b/src/qibocal/protocols/two_qubit_state_tomography.py index 75c9ffbbd..5a1f3405e 100644 --- a/src/qibocal/protocols/two_qubit_state_tomography.py +++ b/src/qibocal/protocols/two_qubit_state_tomography.py @@ -9,7 +9,7 @@ import plotly.graph_objects as go from plotly.subplots import make_subplots from qibo import Circuit, gates -from qibo.backends import GlobalBackend, NumpyBackend +from qibo.backends import NumpyBackend, get_backend from qibo.quantum_info import fidelity, partial_trace from qibo.result import QuantumState @@ -105,7 +105,7 @@ def _acquisition( if params.circuit is None: params.circuit = Circuit(len(qubits)) - backend = GlobalBackend() + backend = get_backend() backend.platform = platform simulator = NumpyBackend() transpiler = dummy_transpiler(backend) diff --git a/tests/test_task_options.py b/tests/test_task_options.py index 2ca178b62..f7cc956ee 100644 --- a/tests/test_task_options.py +++ b/tests/test_task_options.py @@ -4,7 +4,7 @@ import pytest from pytest import approx -from qibo.backends import GlobalBackend, set_backend +from qibo.backends import get_backend, set_backend from qibocal import protocols from qibocal.auto.mode import AUTOCALIBRATION, ExecutionMode @@ -21,7 +21,7 @@ @pytest.fixture(scope="module") def platform(): set_backend(backend="qibolab", platform="dummy") - return CalibrationPlatform.from_platform(GlobalBackend().platform) + return CalibrationPlatform.from_platform(get_backend().platform) TARGETS = [0, 1, 2] diff --git a/tests/test_transpile.py b/tests/test_transpile.py index 499ac9d28..d9f953796 100644 --- a/tests/test_transpile.py +++ b/tests/test_transpile.py @@ -1,6 +1,6 @@ import numpy as np from qibo import Circuit, gates, set_backend -from qibo.backends import GlobalBackend +from qibo.backends import get_backend from qibocal.auto.transpile import ( dummy_transpiler, @@ -30,7 +30,7 @@ def test_execute_transpiled_circuit(): circuit.add(gates.X(1)) qubit_map = [1, 2] set_backend("qibolab", platform="dummy") - backend = GlobalBackend() + backend = get_backend() transpiler = dummy_transpiler(backend) transpiled_circuit, _ = execute_transpiled_circuit( circuit, qubit_map, backend, transpiler=transpiler @@ -52,7 +52,7 @@ def test_execute_transpiled_circuits(): circuit.add(gates.X(1)) qubit_map = [1, 2] set_backend("qibolab", platform="dummy") - backend = GlobalBackend() + backend = get_backend() transpiler = dummy_transpiler(backend) transpiled_circuits, _ = execute_transpiled_circuits( [circuit], [qubit_map], backend, transpiler=transpiler