Skip to content

Commit

Permalink
refactor: remove all deprecated code (qiskit-community#1248)
Browse files Browse the repository at this point in the history
* refactor: remove all deprecated code

This commit removes all deprecated code. Even though this is done a bit
earlier than originally announced under the Qiskit deprecation policy,
we are taking this step now since this project has become part of a
community effort.
As a direct consequence, new codeowners will soon join the team behind
Qiskit Nature. Rather than handing over a codebase that includes pieces
of code which need attention in the near future (and even continued
support until then) we are removing these parts early.

As a consequence, if you still require parts of this code, we suggest
you stick to Qiskit Nature 0.6 until you can transition based on the
provided migration guides.

This commit also removes the deprecation utilities which are superseded
by the ones provided by Qiskit directly (see qiskit.utils.deprecation).

* docs: remove doctest from migration guides

Now that the old code covered by the migration guide is being removed,
doctest can no longer execute this code. Thus, this commit replaces the
doctest directives with simple code cells.

* docs: add 0.7 prelude

* docs: add spelling exceptions

* docs: fix indent in release note

* fix: remove final occurrence of opflow

* lint: run black

* fix: remove final occurrences of removed setting attributes

* docs: removes a now obsolete release note

* fix: remove left over setting
  • Loading branch information
mrossinek authored and ialsina committed Nov 17, 2023
1 parent cbaffb1 commit a5d9a04
Show file tree
Hide file tree
Showing 132 changed files with 1,181 additions and 9,038 deletions.
2 changes: 2 additions & 0 deletions .pylintdict
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ cls
cmap
cnot
codec
codeowners
coeff
coeffs
colormap
Expand Down Expand Up @@ -395,6 +396,7 @@ observables
occupancies
ok
ollitrault
onboarding
onee
oneeints
onsite
Expand Down
11 changes: 0 additions & 11 deletions docs/howtos/adapt_vqe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ algorithm has been migrated to Qiskit Terra (released in v0.22).

This tutorial outlines how the algorithm can be used.

0. We ensure the use of :class:`~qiskit.opflow.primitive_ops.PauliSumOp` (this is the default value
of this setting for now but we enforce it here to ensure stability of this guide as long as the
:class:`~qiskit.algorithms.minimum_eigensolvers.AdaptVQE` class is not yet guaranteed to handle
the :class:`~qiskit.quantum_info.SparsePauliOp` successor properly):

.. testcode::

from qiskit_nature import settings

settings.use_pauli_sum_op = True

1. We obtain an :class:`~qiskit_nature.second_q.problems.ElectronicStructureProblem`
which we want to solve:

Expand Down
18 changes: 9 additions & 9 deletions docs/migration/0.6_b_mes_factory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For the following examples, we need a simple
:class:`~qiskit_nature.second_q.problems.ElectronicStructureProblem` which we can obtain from a
:class:`~qiskit_nature.second_q.drivers.PySCFDriver` like so:

.. testcode::
.. code:: ipython3
from qiskit_nature.second_q.drivers import PySCFDriver
from qiskit_nature.second_q.mappers import ParityMapper
Expand All @@ -58,7 +58,7 @@ VQEUCCFactory

The old way:

.. testcode::
.. code:: ipython3
from qiskit.algorithms.optimizers import SLSQP
from qiskit.primitives import Estimator
Expand All @@ -72,13 +72,13 @@ The old way:
result = solver.compute_minimum_eigenvalue(qubit_op, aux_ops)
print(f"Eigenvalue = {result.eigenvalue: .6f}")
.. testoutput::
.. parsed-literal::
Eigenvalue = -1.857275
And the corresponding new way:

.. testcode::
.. code:: ipython3
from qiskit.algorithms.minimum_eigensolvers import VQE
from qiskit.algorithms.optimizers import SLSQP
Expand Down Expand Up @@ -107,7 +107,7 @@ And the corresponding new way:
result = solver.compute_minimum_eigenvalue(qubit_op, aux_ops)
print(f"Eigenvalue = {result.eigenvalue: .6f}")
.. testoutput::
.. parsed-literal::
Eigenvalue = -1.857275
Expand All @@ -116,7 +116,7 @@ NumPyEigensolverFactory

The old way:

.. testcode::
.. code:: ipython3
from qiskit_nature.second_q.algorithms import NumPyEigensolverFactory
Expand All @@ -132,15 +132,15 @@ The old way:
for idx, eigenvalue in enumerate(result.eigenvalues):
print(f"{idx}: {eigenvalue: .6f}")
.. testoutput::
.. parsed-literal::
0: -1.857275
1: -0.882722
2: -0.224911
And the corresponding new way:

.. testcode::
.. code:: ipython3
from qiskit.algorithms.eigensolvers import NumPyEigensolver
Expand All @@ -152,7 +152,7 @@ And the corresponding new way:
for idx, eigenvalue in enumerate(result.eigenvalues):
print(f"{idx}: {eigenvalue: .6f}")
.. testoutput::
.. parsed-literal::
0: -1.857275
1: -0.882722
Expand Down
34 changes: 17 additions & 17 deletions docs/migration/0.6_c_qubit_converter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Setup
For the examples in this guide, we will always be using the following
:class:`~qiskit_nature.second_q.operators.FermionicOp`:

.. testcode::
.. code:: ipython3
from qiskit_nature.second_q.drivers import PySCFDriver
Expand All @@ -29,7 +29,7 @@ For the examples in this guide, we will always be using the following
for label, coeff in sorted(hamiltonian.items()):
print(f"{coeff:+.8f} * '{label}'")
.. testoutput::
.. parsed-literal::
+0.33785508 * '+_0 +_0 -_0 -_0'
+0.09046560 * '+_0 +_0 -_1 -_1'
Expand Down Expand Up @@ -80,7 +80,7 @@ now set the value of :attr:`~qiskit_nature.settings.QiskitNatureSettings.use_pau
To ensure that we can consistently rely on using the :class:`~qiskit.quantum_info.SparsePauliOp` in
the following parts of this guide, we are applying this setting here:

.. testcode::
.. code:: ipython3
from qiskit_nature import settings
Expand All @@ -102,7 +102,7 @@ In the simplest cases, all you did was pass a :class:`~qiskit_nature.second_q.ma
object into the :class:`~qiskit_nature.second_q.mappers.QubitConverter`. For example, somewhat like
this:

.. testcode::
.. code:: ipython3
from qiskit_nature.second_q.mappers import JordanWignerMapper, QubitConverter
Expand All @@ -115,14 +115,14 @@ object from the example above into whichever place you were using it before.
If you were working directly with some :class:`~qiskit_nature.second_q.operators.SparseLabelOp` like
so:

.. testcode::
.. code:: ipython3
qubit_op = converter.convert(hamiltonian)
for pauli, coeff in sorted(qubit_op.label_iter()):
print(f"{coeff.real:+.8f} * {pauli}")
.. testoutput::
.. parsed-literal::
-0.81054798 * IIII
+0.17218393 * IIIZ
Expand All @@ -142,14 +142,14 @@ so:
You should now directly use the ``mapper`` again, but its method is called ``.map``:

.. testcode::
.. code:: ipython3
qubit_op = mapper.map(hamiltonian)
for pauli, coeff in sorted(qubit_op.label_iter()):
print(f"{coeff.real:+.8f} * {pauli}")
.. testoutput::
.. parsed-literal::
-0.81054798 * IIII
+0.17218393 * IIIZ
Expand Down Expand Up @@ -185,7 +185,7 @@ able to use the ``two_qubit_reduction=True`` option of the
to the :class:`~qiskit_nature.second_q.mappers.ParityMapper`, is now directly built into said
mapper. So if you were doing something along these lines:

.. testcode::
.. code:: ipython3
from qiskit_nature.second_q.mappers import ParityMapper
Expand All @@ -196,7 +196,7 @@ mapper. So if you were doing something along these lines:
for pauli, coeff in sorted(reduced_op.label_iter()):
print(f"{coeff.real:+.8f} * {pauli}")
.. testoutput::
.. parsed-literal::
-1.05237325 * II
+0.39793742 * IZ
Expand All @@ -206,7 +206,7 @@ mapper. So if you were doing something along these lines:
The equivalent code now looks like the following:

.. testcode::
.. code:: ipython3
mapper = ParityMapper(num_particles=problem.num_particles)
Expand All @@ -215,7 +215,7 @@ The equivalent code now looks like the following:
for pauli, coeff in sorted(reduced_op.label_iter()):
print(f"{coeff.real:+.8f} * {pauli}")
.. testoutput::
.. parsed-literal::
-1.05237325 * II
+0.39793742 * IZ
Expand All @@ -235,7 +235,7 @@ name: :class:`~qiskit.quantum_info.analysis.z2_symmetries.Z2Symmetries`), you sh

In the past, you would have enabled this like so:

.. testcode::
.. code:: ipython3
mapper = JordanWignerMapper()
converter = QubitConverter(mapper, z2symmetry_reduction="auto")
Expand All @@ -245,7 +245,7 @@ which would then later use
sector of the Hilbert space in which the solution of your problem lies. This was only supported by
the :class:`~qiskit_nature.second_q.problems.ElectronicStructureProblem`. Below is a quick example:

.. testcode::
.. code:: ipython3
tapered_op = converter.convert(
hamiltonian,
Expand All @@ -256,7 +256,7 @@ the :class:`~qiskit_nature.second_q.problems.ElectronicStructureProblem`. Below
for pauli, coeff in sorted(tapered_op.label_iter()):
print(f"{coeff.real:+.8f} * {pauli}")
.. testoutput::
.. parsed-literal::
-1.04109314 * I
+0.18093120 * X
Expand All @@ -266,7 +266,7 @@ Now, all you need to do is the use the
:meth:`~qiskit_nature.second_q.problems.BaseProblem.get_tapered_mapper` method and provide the
original mapper which you would like to wrap:

.. testcode::
.. code:: ipython3
tapered_mapper = problem.get_tapered_mapper(mapper)
Expand All @@ -275,7 +275,7 @@ original mapper which you would like to wrap:
for pauli, coeff in sorted(tapered_op.label_iter()):
print(f"{coeff.real:+.8f} * {pauli}")
.. testoutput::
.. parsed-literal::
-1.04109314 * I
+0.18093120 * X
Expand Down
Loading

0 comments on commit a5d9a04

Please sign in to comment.