From 599cbf56a11138c694be169d4c23d895e69aabe5 Mon Sep 17 00:00:00 2001 From: Junye Huang Date: Thu, 23 Jun 2022 04:28:30 +0200 Subject: [PATCH] Move `qiskit.test.mock` to `qiskit.providers.fake_provider` and deprecate (#8121) * redirect imports from qiskit.test.mock to qiskit.providers.fake_provider * import the rest of classes in fake_backend_v2 to fake_provider * redirect imports to fake_provider Anything that can be imported from fake_provider root are imported from there instead of sub files. * change jupyter-execute to code-block * redirect import * Combine multiple imports into one * Add missing ) * move all files except __init__ from qiskit.test.mock to qiskit.providers.fake_provider * redirect imports in fake_provider.__init__.py * redirect imports in mock.__init__.py * Use relative imports in fake_provider.__init__.py * redirect .utlis imports * Don't import fake_backend_v2.py in __init__ to avoid clashes of FakeBackendV2 names * Match imports from the old and new __init__ * Organize imports * black linting * Fix FakePulseBackend import order dependency * fix cyclic import * move relative import after absolute import * fix cyclic import * Update MANIFEST.ini with new path * add deprecation warning * add deprecation test * add release note * move test files from test.python.mock to test.python.providers.fake_provider * linting * linting * change deprecation warning location * update path for tools/update_fake_backends.py * rename docstrings * Update ibmq_mock.py * import back FakeBackendV2 and FakeBackend5QV2 in __init__ * Modify release note * reformat release note * remove unnecessary tests These two tests were introduced in PR #7437 to test the new imports which are not needed any more: https://github.com/Qiskit/qiskit-terra/pull/7437#discussion_r810843786 * Use relative imports * redirect import in test_schedular.py * first draft of module level doc * Update docstring of fake provider v1 and v2 * Update wording of module level doc * add fake V1 and V2 backends * Correct fake v1 and v2 backends in the list * comment on backends that do not have V2 versions * list special fake backends * Add descriptions for sections * add code example using jupyter execute * Update code example and improve descriptions of the module * not using fake provider before fake provider get backend name is fixed * modify comment * formating fix * Remove fake backend coupling map from docstrings * linting * remove coupling map of Pooughkeepsie * add qiskit-aer to tox.ini as deps for docs build * Revert "remove coupling map of Pooughkeepsie" This reverts commit 45607489303fde0e65e550f117735ec4f468ff3d. * Revert "linting" This reverts commit eddfa65bf6f65f076c7eff4d1a20bb251c56658b. * Revert "Remove fake backend coupling map from docstrings" This reverts commit 3aee7a8b57e8ea248ede0bec9db67e02dcb08eed. * fix coupling maps * Fix minor typos * Issue deprecation warnings from all levels of package The previous commits in this PR did not maintain the old import paths for submodules of `qisit.test.mock`. This re-instatates them, with suitable deprecation warnings. Hopefully nobody is using these anyway, but it's better to be on the safe side. * Import from the correct location Co-authored-by: Jake Lishman Co-authored-by: Jake Lishman Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- test/python/algorithms/test_backendv1.py | 2 +- test/python/algorithms/test_backendv2.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/python/algorithms/test_backendv1.py b/test/python/algorithms/test_backendv1.py index 484ec99d4ed4..aa251841e744 100644 --- a/test/python/algorithms/test_backendv1.py +++ b/test/python/algorithms/test_backendv1.py @@ -15,7 +15,7 @@ import unittest from test.python.algorithms import QiskitAlgorithmsTestCase from qiskit import QuantumCircuit -from qiskit.test.mock import FakeProvider +from qiskit.providers.fake_provider import FakeProvider from qiskit.utils import QuantumInstance, algorithm_globals from qiskit.algorithms import Shor, VQE, Grover, AmplificationProblem from qiskit.opflow import X, Z, I diff --git a/test/python/algorithms/test_backendv2.py b/test/python/algorithms/test_backendv2.py index e96d5d2176bf..27cf0f7cfb86 100644 --- a/test/python/algorithms/test_backendv2.py +++ b/test/python/algorithms/test_backendv2.py @@ -15,8 +15,8 @@ import unittest from test.python.algorithms import QiskitAlgorithmsTestCase from qiskit import QuantumCircuit -from qiskit.test.mock import FakeProvider -from qiskit.test.mock.fake_backend_v2 import FakeBackendSimple +from qiskit.providers.fake_provider import FakeProvider +from qiskit.providers.fake_provider.fake_backend_v2 import FakeBackendSimple from qiskit.utils import QuantumInstance from qiskit.algorithms import Shor, VQE, Grover, AmplificationProblem from qiskit.opflow import X, Z, I