Skip to content

Commit

Permalink
qiskit-terra == qiskit, in version libraries (#10425)
Browse files Browse the repository at this point in the history
* __qiskit_version__ deprecation

* reno

* reno feature

* PackageNotFoundError

* revert stacklevel=2

* revert change in test

* remove OrderedDict

* other qiskit.__qiskit_version__  packages have their own __version__

* wording in the reno

* qiskit-terra == qiskit in version libraries

* lint

* readjust test

* raise an exception with a custom gate with no qubits or with one-or-more clbits

* QASM2ExportError

* test_circuit_raises_invalid_custom_gate_1

* test_circuit_raises_invalid_custom_gate_2

* reno

* revert

* revert

* adapt test

* reno

* conflicts
  • Loading branch information
1ucian0 authored Sep 1, 2023
1 parent e1fdb72 commit 8b03010
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 30 deletions.
14 changes: 2 additions & 12 deletions qiskit/tools/jupyter/version_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,14 @@ def qiskit_version_table(self, line="", cell=None):
html += "<table>"
html += "<tr><th>Software</th><th>Version</th></tr>"

packages = {"qiskit": None}

packages["qiskit-terra"] = qiskit.__version__

packages = {"qiskit": qiskit.__version__}
qiskit_modules = {module.split(".")[0] for module in modules.keys() if "qiskit" in module}

for qiskit_module in qiskit_modules:
packages[qiskit_module] = getattr(modules[qiskit_module], "__version__", None)

from importlib.metadata import metadata, PackageNotFoundError

try:
packages["qiskit"] = metadata("qiskit")["Version"]
except PackageNotFoundError:
packages["qiskit"] = None

for name, version in packages.items():
if name == "qiskit" or version:
if version:
html += f"<tr><td><code>{name}</code></td><td>{version}</td></tr>"

html += "<tr><th colspan='2'>System information</th></tr>"
Expand Down
14 changes: 7 additions & 7 deletions qiskit/utils/optionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""
.. currentmodule:: qiskit.utils.optionals
Qiskit Terra, and many of the other Qiskit components, have several features that are enabled only
Qiskit has several features that are enabled only
if certain *optional* dependencies are satisfied. This module is a collection of objects that can
be used to test if certain functionality is available, and optionally raise
:class:`.MissingOptionalLibraryError` if the functionality is not available.
Expand All @@ -30,7 +30,7 @@
* - .. py:data:: HAS_AER
- :mod:`Qiskit Aer <qiskit.providers.aer>` provides high-performance simulators for the
quantum circuits constructed within Qiskit Terra.
quantum circuits constructed within Qiskit.
* - .. py:data:: HAS_IBMQ
- The :mod:`Qiskit IBMQ Provider <qiskit.providers.ibmq>` is used for accessing IBM Quantum
Expand Down Expand Up @@ -92,12 +92,12 @@
interactivity features.
* - .. py:data:: HAS_MATPLOTLIB
- Qiskit Terra provides several visualisation tools in the :mod:`.visualization` module.
- Qiskit provides several visualisation tools in the :mod:`.visualization` module.
Almost all of these are built using `Matplotlib <https://matplotlib.org/>`__, which must
be installed in order to use them.
* - .. py:data:: HAS_NETWORKX
- No longer used by Terra. Internally, Qiskit now uses the high-performance `rustworkx
- No longer used by Qiskit. Internally, Qiskit now uses the high-performance `rustworkx
<https://github.com/Qiskit/rustworkx>`__ library as a core dependency, and during the
change-over period, it was sometimes convenient to convert things into the Python-only
`NetworkX <https://networkx.org/>`__ format. Some tests of application modules, such as
Expand Down Expand Up @@ -132,7 +132,7 @@
<https://qiskit.github.io/qiskit-qasm3-import>`__.
* - .. py:data:: HAS_SEABORN
- Qiskit Terra provides several visualisation tools in the :mod:`.visualization` module. Some
- Qiskit provides several visualisation tools in the :mod:`.visualization` module. Some
of these are built using `Seaborn <https://seaborn.pydata.org/>`__, which must be installed
in order to use them.
Expand All @@ -156,13 +156,13 @@
:class:`~.circuit.Parameter`\\ s if available.
* - .. py:data:: HAS_TESTTOOLS
- Qiskit Terra's test suite has more advanced functionality available if the optional
- Qiskit's test suite has more advanced functionality available if the optional
`testtools <https://pypi.org/project/testtools/>`__ library is installed. This is generally
only needed for Qiskit developers.
* - .. py:data:: HAS_TWEEDLEDUM
- `Tweedledum <https://github.com/boschmitt/tweedledum>`__ is an extension library for
synthesis and optimization of circuits that may involve classical oracles. Qiskit Terra's
synthesis and optimization of circuits that may involve classical oracles. Qiskit's
:class:`.PhaseOracle` uses this, which is used in turn by amplification algorithms via
the :class:`.AmplificationProblem`.
Expand Down
12 changes: 2 additions & 10 deletions qiskit/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# pylint: disable=no-name-in-module,broad-except,cyclic-import

"""Contains Qiskit (terra) version."""
"""Contains Qiskit version."""

import os
import subprocess
Expand Down Expand Up @@ -94,8 +94,7 @@ class QiskitVersion(Mapping):

def __init__(self):
self._version_dict = {
"qiskit-terra": __version__,
"qiskit": None,
"qiskit": __version__,
}
self._loaded = False

Expand All @@ -109,9 +108,6 @@ def _load_versions(self):
category=DeprecationWarning,
stacklevel=3,
)

from importlib.metadata import version

try:
# TODO: Update to use qiskit_aer instead when we remove the
# namespace redirect
Expand Down Expand Up @@ -156,10 +152,6 @@ def _load_versions(self):
self._version_dict["qiskit-machine-learning"] = qiskit_machine_learning.__version__
except Exception:
self._version_dict["qiskit-machine-learning"] = None
try:
self._version_dict["qiskit"] = version("qiskit")
except Exception:
self._version_dict["qiskit"] = None
self._loaded = True

def __repr__(self):
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/qiskit_terra_version-956916f7b8d7bbb9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
The magic ``%qiskit_version_table`` from ``qiskit.tools.jupyter`` and the deprecated ``qiskit.__qiskit_version__`` do not include `qiskit-terra` anymore. Now Qiskit Terra is called Qiskit.
2 changes: 1 addition & 1 deletion test/python/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ class TestVersion(QiskitTestCase):
def test_qiskit_version(self):
"""Test qiskit-version sets the correct version for terra."""
with self.assertWarnsRegex(DeprecationWarning, "__qiskit_version__"):
self.assertEqual(__version__, __qiskit_version__["qiskit-terra"])
self.assertEqual(__version__, __qiskit_version__["qiskit"])

0 comments on commit 8b03010

Please sign in to comment.