From 4410ed175a19db785bf70d0c73865618cd9ffa7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 10:41:15 +0200 Subject: [PATCH 01/31] Add docs from terra + dummy tutorial --- docs/Makefile | 28 ++ docs/_templates/autosummary/class.rst | 31 ++ .../class_no_inherited_members.rst | 28 ++ docs/apidocs/algorithms.rst | 3 + docs/conf.py | 118 ++++++ docs/index.rst | 16 + docs/release_notes.rst | 1 + .../01_algorithms_introduction.ipynb | 338 ++++++++++++++++++ docs/tutorials/index.rst | 16 + 9 files changed, 579 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/_templates/autosummary/class.rst create mode 100644 docs/_templates/autosummary/class_no_inherited_members.rst create mode 100644 docs/apidocs/algorithms.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/release_notes.rst create mode 100644 docs/tutorials/01_algorithms_introduction.ipynb create mode 100644 docs/tutorials/index.rst diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..dce383c9 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,28 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2018. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst new file mode 100644 index 00000000..daff18c1 --- /dev/null +++ b/docs/_templates/autosummary/class.rst @@ -0,0 +1,31 @@ +{# + We show all the class's methods and attributes on the same page. By default, we document + all methods, including those defined by parent classes. +-#} + +{{ objname | escape | underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :no-members: + :show-inheritance: + +{% block attributes_summary %} + {% if attributes %} + .. rubric:: Attributes + {% for item in attributes %} + .. autoattribute:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock -%} + +{% block methods_summary %} + {% set wanted_methods = (methods | reject('==', '__init__') | list) %} + {% if wanted_methods %} + .. rubric:: Methods + {% for item in wanted_methods %} + .. automethod:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock %} diff --git a/docs/_templates/autosummary/class_no_inherited_members.rst b/docs/_templates/autosummary/class_no_inherited_members.rst new file mode 100644 index 00000000..269a89b7 --- /dev/null +++ b/docs/_templates/autosummary/class_no_inherited_members.rst @@ -0,0 +1,28 @@ +{# This is identical to class.rst, except for the filtering in `set wanted_methods`. -#} + +{{ objname | escape | underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :no-members: + :show-inheritance: + +{% block attributes_summary %} + {% if attributes %} + .. rubric:: Attributes + {% for item in attributes %} + .. autoattribute:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock -%} + +{% block methods_summary %} + {% set wanted_methods = (methods | reject('in', inherited_members) | reject('==', '__init__') | list) %} + {% if wanted_methods %} + .. rubric:: Methods + {% for item in wanted_methods %} + .. automethod:: {{ item }} + {%- endfor %} + {% endif %} +{% endblock %} diff --git a/docs/apidocs/algorithms.rst b/docs/apidocs/algorithms.rst new file mode 100644 index 00000000..16b6646b --- /dev/null +++ b/docs/apidocs/algorithms.rst @@ -0,0 +1,3 @@ +.. _qiskit-algorithms: + +.. module:: qiskit_algorithms diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..91561139 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,118 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2018. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +# pylint: disable=invalid-name + +"""Sphinx documentation builder.""" + +# -- General configuration --------------------------------------------------- +import datetime +import doctest + +project = "Qiskit Algorithms" +copyright = f"2017-{datetime.date.today().year}, Qiskit Algorithms Development Team" # pylint: disable=redefined-builtin +author = "Qiskit Algorithms Development Team" + +# The short X.Y version +version = "0.1" +# The full version, including alpha/beta/rc tags +release = "0.1.0" + +extensions = [ + "sphinx.ext.napoleon", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.mathjax", + "sphinx.ext.viewcode", + "sphinx.ext.extlinks", + "sphinx.ext.intersphinx", + "sphinx.ext.doctest", + "reno.sphinxext", + "sphinx_design", + "matplotlib.sphinxext.plot_directive", + "sphinx.ext.doctest" +] + +templates_path = ["_templates"] + +# Number figures, tables and code-blocks if they have a caption. +numfig = True +# Available keys are 'figure', 'table', 'code-block' and 'section'. '%s' is the number. +numfig_format = {"table": "Table %s"} + +# The language for content autogenerated by Sphinx or the default for gettext content translation. +language = "en" + +# Relative to source directory, affects general discovery, and html_static_path and html_extra_path. +exclude_patterns = ["_build", "**.ipynb_checkpoints"] + +pygments_style = "colorful" + +# Whether module names are included in crossrefs of functions, classes, etc. +add_module_names = False + +# A list of prefixes that are ignored for sorting the Python module index +# (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F). +modindex_common_prefix = ["qiskit."] + +intersphinx_mapping = { + "rustworkx": ("https://qiskit.org/ecosystem/rustworkx/", None), + "qiskit-ibm-runtime": ("https://qiskit.org/ecosystem/ibm-runtime/", None), + "qiskit-aer": ("https://qiskit.org/ecosystem/aer/", None), + "numpy": ("https://numpy.org/doc/stable/", None), + "matplotlib": ("https://matplotlib.org/stable/", None), +} + +# -- Options for HTML output ------------------------------------------------- + +html_theme = "qiskit_sphinx_theme" +html_last_updated_fmt = "%Y/%m/%d" +html_theme_options = { + "logo_only": True, + "display_version": True, + "prev_next_buttons_location": "bottom", + "style_external_links": True, +} + + +# -- Options for Autosummary and Autodoc ------------------------------------- + +# Note that setting autodoc defaults here may not have as much of an effect as you may expect; any +# documentation created by autosummary uses a template file (in autosummary in the templates path), +# which likely overrides the autodoc defaults. + +# Move type hints from signatures to the parameter descriptions (except in overload cases, where +# that's not possible). +autodoc_typehints = "description" +# Only add type hints from signature to description body if the parameter has documentation. The +# return type is always added to the description (if in the signature). +autodoc_typehints_description_target = "documented_params" + +autosummary_generate = True +autosummary_generate_overwrite = False +autoclass_content = "both" + + +# -- Options for Doctest -------------------------------------------------------- + +doctest_default_flags = ( + doctest.ELLIPSIS + | doctest.NORMALIZE_WHITESPACE + | doctest.IGNORE_EXCEPTION_DETAIL + | doctest.DONT_ACCEPT_TRUE_FOR_1 +) + +# Leaving this string empty disables testing of doctest blocks from docstrings. +# Doctest blocks are structures like this one: +# >> code +# output +doctest_test_doctest_blocks = "" diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..864cf668 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,16 @@ +################################ +Qiskit Algorithms documentation +################################ + +.. toctree:: + :maxdepth: 2 + :hidden: + + API References + Tutorials + Release Notes + +.. Hiding - Indices and tables + :ref:`genindex` + :ref:`modindex` + :ref:`search` diff --git a/docs/release_notes.rst b/docs/release_notes.rst new file mode 100644 index 00000000..ec77acc3 --- /dev/null +++ b/docs/release_notes.rst @@ -0,0 +1 @@ +.. release-notes:: Release Notes diff --git a/docs/tutorials/01_algorithms_introduction.ipynb b/docs/tutorials/01_algorithms_introduction.ipynb new file mode 100644 index 00000000..13baa14e --- /dev/null +++ b/docs/tutorials/01_algorithms_introduction.ipynb @@ -0,0 +1,338 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# An Introduction to Algorithms in Qiskit\n", + "\n", + "This is an introduction to algorithms in Qiskit and provides a high-level overview to help understand the various aspects of the functionality to get started. Other tutorials will provide more in-depth material, on given algorithms, and ways to use them etc." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How is the algorithm library structured?\n", + "\n", + "Qiskit provides a number of [Algorithms](https://qiskit.org/documentation/apidoc/algorithms.html) and they are grouped by category according to the task they can perform. For instance `Minimum Eigensolvers` to find the smallest eigen value of an operator, for example ground state energy of a chemistry Hamiltonian or a solution to an optimization problem when expressed as an Ising Hamiltonian. There are `Time Evolvers` for the time evolution of quantum systems and `Amplitude Estimators` for value estimation that can be used say in financial applications. The full set of categories can be seen in the Algorithms documentation link above.\n", + "\n", + "Algorithms are configurable and often part of the configuration will be in the form of smaller building blocks, of which different instances of the building block type can be given. For instance with `VQE`, the Variational Quantum Eigensolver, it takes a trial wavefunction, in the form of a `QuantumCircuit` and a classical optimizer among other things.\n", + "\n", + "Let's take a look at an example to construct a VQE instance. Here `TwoLocal` is the variational form (trial wavefunction), a parameterized circuit which can be varied, and `SLSQP` a classical optimizer. These are created as separate instances and passed to VQE when it is constructed. Trying, for example, a different classical optimizer, or variational form is simply a case of creating an instance of the one you want and passing it into VQE." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from qiskit_algorithms.optimizers import SLSQP\n", + "from qiskit.circuit.library import TwoLocal\n", + "\n", + "num_qubits = 2\n", + "ansatz = TwoLocal(num_qubits, \"ry\", \"cz\")\n", + "optimizer = SLSQP(maxiter=1000)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's draw the ansatz so we can see it's a `QuantumCircuit` where θ\\[0\\] through θ\\[7\\] will be the parameters that are varied as VQE optimizer finds the minimum eigenvalue. We'll come back to the parameters later in a working example below." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAB7CAYAAACIG9xhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAW2klEQVR4nO3deVzUBf7H8dcMN6Kh4pl3AioKHnmtGXmkqG2tWpqt5UrrgUbXWm25rRmbtupvyw4rM1Mr1lI7zJRSNNaz0EhFVDJRxAMVRRgOYZjv7w90lJDhK8f3+53p83w85vGQ73xr3rwfM/OZ7zFfTIqiKAghhBAqmPUOIIQQwnnI0BBCCKGaDA0hhBCqydAQQgihmgwNIYQQqsnQEEIIoZoMDSGEEKrJ0BBCCKGaDA0hhBCqydAQQgihmgwNIYQQqsnQEEIIoZoMDSGEEKrJ0BBCCKGaDA0hhBCqydAQQgihmgwNIYQQqsnQEEIIoZoMDSGEEKrJ0BBCCKGaDA0hhBCqydAQQgihmgwNIYQQqsnQEEIIoZoMDSGEEKrJ0BBCCKGau94BjO6HFz/kwoE0XR67QUhbesdM1OWx9SBda0e61o5eXddWzzI0KnHhQBqZO1P0jvG7IF1rR7rWjqt1LbunhBBCqCZDQwghhGoyNIQQQqgmQ0MIIYRqciC8hkSsmU2jHkHYrFaUEhuW9LPsXfg5x9ft1DuaS5GetSNda8eZupahUYP2vr6afa+vweRmpmPkMMIXPcEXyWnkHjujdzSXIj1rR7rWjrN0LbunaoFSYiP1402YPdxpENJG7zguS3rWjnStHaN3LUOjFpg93AmeMBSAnKOndU7juqRn7UjX2jF617J7qgaFPj6KzlPvxd3PG6W4hO1PL+LiweMA3LnoSY6t3U56XCIAAz98lpQl6zmzPVnPyOUU5xdizSvE85Y6uHl66B3nhlyhZ4BiSwHWgst4+fth9jDmS9FVui7KycNWZMWzvh9mNze949yQs3Rt6C0Nm83GggULCAwM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7f98GMWmcDnbwtboN3RO69wcdV2vXTP6vTYNa/5lco9n8vP8z3RO69wqew9pdkdnTm8zzh+3kqFRA36aE2v/d+sRfegSPZKctNNk7kwhYcp/yq0/aMXzFGRma5jQdTjqOm5U+SuFStdV56jrr4c8W2596brqHHV96vu9nPp+b5n19exahkYNO/7NLo5/s8vhOnJqYs2QrrUjXWvH6F3L0KhEg5C2v8vH1oN0rR3pWjt6/b619bgmRS7UJIQQQiU51UcIIYRqMjSEEEKoJkNDCCGEajI0hBBCqCZDQwghhGoyNIQQQqgmQ0MIIYRqMjSEEEKoJkNDCCGEajI0hBBCqCZDQwghhGoyNIQQQqgmQ0MIIYRqMjSEEEKoJkNDCCGEajI0hBBCqCZDQwghhGoyNIQQQqj2/y53nt/BUk9dAAAAAElFTkSuQmCC", + "text/plain": [ + "
" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ansatz.decompose().draw(\"mpl\", style=\"iqx\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "But more is needed before we can run the algorithm so let's get to that next." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to run an algorithm?\n", + "\n", + "Algorithms rely on the primitives to evaluate expectation values or sample circuits. The primitives can be based on a simulator or real device and can be used interchangeably in the algorithms, as they all implement the same interface.\n", + "\n", + "In the VQE, we have to evaluate expectation values, so for example we can use the `qiskit.primitives.Estimator` which is shipped with the default Qiskit Terra installation." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "from qiskit.primitives import Estimator\n", + "\n", + "estimator = Estimator()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This estimator uses an exact, statevector simulation to evaluate the expectation values. We can also use a shot-based and noisy simulators or real backends instead. For more information of the simulators you can check out [Qiskit Aer](https://qiskit.org/documentation/apidoc/aer_primitives.html) and for the actual hardware [Qiskit IBM Runtime](https://qiskit.org/documentation/partners/qiskit_ibm_runtime/).\n", + "\n", + "With all the ingredients ready, we can now instantiate the VQE:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "from qiskit_algorithms.minimum_eigensolvers import VQE\n", + "\n", + "vqe = VQE(estimator, ansatz, optimizer)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we can call the [compute_mininum_eigenvalue()](https://qiskit.org/documentation/stubs/qiskit_algorithms.minimum_eigensolvers.VQE.compute_minimum_eigenvalue.html#qiskit_algorithms.minimum_eigensolvers.VQE.compute_minimum_eigenvalue) method. The latter is the interface of choice for the application modules, such as Nature and Optimization, in order that they can work interchangeably with any algorithm within the specific category." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## A complete working example\n", + "\n", + "Let's put what we have learned from above together and create a complete working example. VQE will find the minimum eigenvalue, i.e. minimum energy value of a Hamiltonian operator and hence we need such an operator for VQE to work with. Such an operator is given below. This was originally created by the Nature application module as the Hamiltonian for an H2 molecule at 0.735A interatomic distance. It's a sum of Pauli terms as below, but for now I am not going to say anything further about it since the goal is to run the algorithm, but further information on operators can be found in other tutorials." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "from qiskit.quantum_info import SparsePauliOp\n", + "\n", + "H2_op = SparsePauliOp.from_list([\n", + " (\"II\", -1.052373245772859),\n", + " (\"IZ\", 0.39793742484318045),\n", + " (\"ZI\", -0.39793742484318045),\n", + " (\"ZZ\", -0.01128010425623538),\n", + " (\"XX\", 0.18093119978423156)\n", + "])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "So let's run VQE and print the result object it returns." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ 'aux_operators_evaluated': None,\n", + " 'cost_function_evals': 102,\n", + " 'eigenvalue': -1.857275020719397,\n", + " 'optimal_circuit': ,\n", + " 'optimal_parameters': { ParameterVectorElement(θ[0]): -2.403507257619715,\n", + " ParameterVectorElement(θ[5]): 1.7060524493254914,\n", + " ParameterVectorElement(θ[1]): 3.085467047665086,\n", + " ParameterVectorElement(θ[2]): -2.1949965223522487,\n", + " ParameterVectorElement(θ[3]): 4.276089268519914,\n", + " ParameterVectorElement(θ[4]): -3.098644972035885,\n", + " ParameterVectorElement(θ[6]): 0.032773583818940334,\n", + " ParameterVectorElement(θ[7]): 2.8861019033185396},\n", + " 'optimal_point': array([-2.40350726, 3.08546705, -2.19499652, 4.27608927, -3.09864497,\n", + " 1.70605245, 0.03277358, 2.8861019 ]),\n", + " 'optimal_value': -1.857275020719397,\n", + " 'optimizer_evals': None,\n", + " 'optimizer_result': ,\n", + " 'optimizer_time': 0.29071593284606934}\n" + ] + } + ], + "source": [ + "result = vqe.compute_minimum_eigenvalue(H2_op)\n", + "print(result)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "From the above result we can see the number of cost function (=energy) evaluations the optimizer took until it found the minimum eigenvalue of $\\approx -1.85727$ which is the electronic ground state energy of the given H2 molecule. The optimal parameters of the ansatz can also be seen which are the values that were in the ansatz at the minimum value." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Updating the primitive inside VQE\n", + "\n", + "To close off let's also change the estimator primitive inside the a VQE. Maybe you're satisfied with the simulation results and now want to use a shot-based simulator, or run on hardware!\n", + "\n", + "In this example we're changing to a shot-based estimator, still using Qiskit Terra's reference primitive. However you could replace the primitive by e.g. Qiskit Aer's estimator (`qiskit_aer.primitives.Estimator`) or even a real backend (`qiskit_ibm_runtime.Estimator`).\n", + "\n", + "For noisy loss functions, the SPSA optimizer typically performs well, so we also update the optimizer. See also the [noisy VQE tutorial](https://qiskit.org/documentation/tutorials/algorithms/03_vqe_simulation_with_noise.html) for more details on shot-based and noisy simulations." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ 'aux_operators_evaluated': None,\n", + " 'cost_function_evals': 200,\n", + " 'eigenvalue': -1.8574503552440247,\n", + " 'optimal_circuit': ,\n", + " 'optimal_parameters': { ParameterVectorElement(θ[0]): -7.7940259581467375,\n", + " ParameterVectorElement(θ[5]): 0.28827257835035214,\n", + " ParameterVectorElement(θ[1]): -1.8091021117029589,\n", + " ParameterVectorElement(θ[2]): -2.460381278734678,\n", + " ParameterVectorElement(θ[3]): -7.725013961075425,\n", + " ParameterVectorElement(θ[4]): -1.3793338621798832,\n", + " ParameterVectorElement(θ[6]): -2.4148423942537587,\n", + " ParameterVectorElement(θ[7]): -1.8555574263247812},\n", + " 'optimal_point': array([-7.79402596, -1.80910211, -2.46038128, -7.72501396, -1.37933386,\n", + " 0.28827258, -2.41484239, -1.85555743]),\n", + " 'optimal_value': -1.8574503552440247,\n", + " 'optimizer_evals': None,\n", + " 'optimizer_result': ,\n", + " 'optimizer_time': 0.8142139911651611}\n" + ] + } + ], + "source": [ + "from qiskit_algorithms.optimizers import SPSA\n", + "\n", + "estimator = Estimator(options={\"shots\": 1000})\n", + "\n", + "vqe.estimator = estimator\n", + "vqe.optimizer = SPSA(maxiter=100)\n", + "result = vqe.compute_minimum_eigenvalue(operator=H2_op)\n", + "print(result)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note: We do not fix the random seed in the simulators here, so re-running gives slightly varying results." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This concludes this introduction to algorithms in Qiskit. Please check out the other algorithm tutorials in this series for both broader as well as more in depth coverage of the algorithms." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "

Version Information

Qiskit SoftwareVersion
qiskit-terra0.23.0.dev0+f52bb33
qiskit-aer0.11.1
qiskit-ignis0.7.1
qiskit-ibmq-provider0.19.2
qiskit-nature0.5.0
qiskit-optimization0.5.0
qiskit-machine-learning0.6.0
System information
Python version3.10.4
Python compilerClang 12.0.0
Python buildmain, Mar 31 2022 03:38:35
OSDarwin
CPUs4
Memory (Gb)32.0
Wed Dec 07 11:02:26 2022 CET
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "

This code is a part of Qiskit

© Copyright IBM 2017, 2022.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import qiskit.tools.jupyter\n", + "%qiskit_version_table\n", + "%qiskit_copyright" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.6 ('venv': venv)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + }, + "vscode": { + "interpreter": { + "hash": "f8729fd834348017bca17aea688b306f536a675180840f7307eb909fff39c285" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} \ No newline at end of file diff --git a/docs/tutorials/index.rst b/docs/tutorials/index.rst new file mode 100644 index 00000000..b08c5092 --- /dev/null +++ b/docs/tutorials/index.rst @@ -0,0 +1,16 @@ +###################### +Algorithms Tutorials +###################### + + +.. nbgallery:: + :glob: + + * + + +.. Hiding - Indices and tables + :ref:`genindex` + :ref:`modindex` + :ref:`search` + From c1440b9cf4276433cee8927083e180e13174d2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 10:54:39 +0200 Subject: [PATCH 02/31] Update requirements-dev --- requirements-dev.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 9271ef3a..0755ce3d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,9 +1,19 @@ coverage>=4.4.0,<7.0 matplotlib>=3.3 -black~=22.0 +jupyter +black[jupyter]~=22.0 pylint>=2.15.0 stestr>=2.0.0 -ddt>=1.2.0,!=1.4.0 -reno>=3.4.0 +pylatexenc>=1.4 +ddt>=1.2.0,!=1.4.0,!=1.4.3 +seaborn>=0.9.0 +reno>=3.4.0å +Sphinx>=5.0 +nbsphinx +qiskit-sphinx-theme~=1.11.0 +sphinx-design>=0.2.0 +sphinxcontrib-spelling +jupyter-sphinx discover +docplex rustworkx>=0.13 From 4df457b234772ff1bb34608b5ba4a95e94433954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 10:54:50 +0200 Subject: [PATCH 03/31] Update index --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 864cf668..a7d8b7ad 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,7 +6,7 @@ Qiskit Algorithms documentation :maxdepth: 2 :hidden: - API References + API References Tutorials Release Notes From 7b786642f01065b4bf0cdcd92b0d0457721b0df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 11:25:43 +0200 Subject: [PATCH 04/31] Update init --- qiskit_algorithms/__init__.py | 70 ----------------------------------- 1 file changed, 70 deletions(-) diff --git a/qiskit_algorithms/__init__.py b/qiskit_algorithms/__init__.py index c9949c82..091f23f6 100644 --- a/qiskit_algorithms/__init__.py +++ b/qiskit_algorithms/__init__.py @@ -23,13 +23,6 @@ a different implementation of the same component type in order to potentially alter the behavior and outcome of the algorithm. -Quantum algorithms are run via a :class:`~qiskit_algorithms.QuantumInstance` -which must be set with the -desired backend where the algorithm's circuits will be executed and be configured with a number of -compile and runtime parameters controlling circuit compilation and execution. It ultimately uses -`Terra `__ for the actual compilation and execution of the quantum -circuits created by the algorithm and its components. - .. currentmodule:: qiskit_algorithms Algorithms @@ -92,23 +85,6 @@ eigensolvers -Legacy Eigensolvers -+++++++++++++++++++ - -These algorithms, still based on the :class:`.QuantumInstance`, are superseded -by the primitive-based versions in the section above but are still supported for now. - -.. autosummary:: - :toctree: ../stubs/ - :nosignatures: - - Eigensolver - EigensolverResult - NumPyEigensolver - VQD - VQDResult - - Time Evolvers ------------- @@ -138,23 +114,6 @@ VarQITE VarQRTE -Legacy Time Evolvers -++++++++++++++++++++ - -These algorithms, still based on the :class:`.QuantumInstance`, are superseded -by the primitive-based versions in the section above but are still supported for now. - -.. autosummary:: - :toctree: ../stubs/ - :nosignatures: - - RealEvolver - ImaginaryEvolver - TrotterQRTE - EvolutionResult - EvolutionProblem - - Variational Quantum Time Evolution ++++++++++++++++++++++++++++++++++ @@ -209,23 +168,6 @@ minimum_eigensolvers -Legacy Minimum Eigensolvers -+++++++++++++++++++++++++++ - -These algorithms, still based on the :class:`.QuantumInstance`, are superseded -by the primitive-based versions in the section above but are still supported for now. - -.. autosummary:: - :toctree: ../stubs/ - :nosignatures: - - MinimumEigensolver - MinimumEigensolverResult - NumPyMinimumEigensolver - QAOA - VQE - - Optimizers ---------- @@ -274,18 +216,6 @@ AlgorithmError -Utility methods ---------------- - -Utility methods used by algorithms. - -.. autosummary:: - :toctree: ../stubs/ - - eval_observables - estimate_observables - - Utility classes --------------- From 836903f292ccd8b776fad2297750de12e4f92fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 11:25:54 +0200 Subject: [PATCH 05/31] Update config --- docs/apidocs/algorithms.rst | 5 ++++- docs/conf.py | 6 ++++++ docs/index.rst | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/apidocs/algorithms.rst b/docs/apidocs/algorithms.rst index 16b6646b..ce2ad817 100644 --- a/docs/apidocs/algorithms.rst +++ b/docs/apidocs/algorithms.rst @@ -1,3 +1,6 @@ .. _qiskit-algorithms: -.. module:: qiskit_algorithms +.. automodule:: qiskit_algorithms + :no-members: + :no-inherited-members: + :no-special-members: diff --git a/docs/conf.py b/docs/conf.py index 91561139..d570f819 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,6 +18,12 @@ import datetime import doctest +import os +import sys + +sys.path.insert(0, os.path.abspath("..")) +sys.path.append(os.path.abspath(".")) + project = "Qiskit Algorithms" copyright = f"2017-{datetime.date.today().year}, Qiskit Algorithms Development Team" # pylint: disable=redefined-builtin author = "Qiskit Algorithms Development Team" diff --git a/docs/index.rst b/docs/index.rst index a7d8b7ad..b48b7e35 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,13 +2,14 @@ Qiskit Algorithms documentation ################################ + .. toctree:: - :maxdepth: 2 :hidden: API References Tutorials Release Notes + GitHub .. Hiding - Indices and tables :ref:`genindex` From 334301232dfdbdd9df4d59178f32a07765d17414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 11:32:09 +0200 Subject: [PATCH 06/31] Fix copyright --- docs/Makefile | 2 +- docs/conf.py | 2 +- requirements-dev.txt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index dce383c9..e87c8596 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2018. +# (C) Copyright IBM 2018, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/docs/conf.py b/docs/conf.py index d570f819..4c1a4940 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2018. +# (C) Copyright IBM 2018, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/requirements-dev.txt b/requirements-dev.txt index 0755ce3d..c4ed8a52 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,10 +7,10 @@ stestr>=2.0.0 pylatexenc>=1.4 ddt>=1.2.0,!=1.4.0,!=1.4.3 seaborn>=0.9.0 -reno>=3.4.0å +reno>=3.4.0 Sphinx>=5.0 nbsphinx -qiskit-sphinx-theme~=1.11.0 +qiskit-sphinx-theme>=1.11.0 sphinx-design>=0.2.0 sphinxcontrib-spelling jupyter-sphinx From 4bee4721029a3c31f2314007fa54bed4462aab98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 11:49:38 +0200 Subject: [PATCH 07/31] Add config to makefile --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bcd230e5..06d21f82 100644 --- a/Makefile +++ b/Makefile @@ -35,9 +35,9 @@ endif # You can set this variable from the command line. SPHINXOPTS = -.PHONY: lint style black test test_ci spell copyright coverage clean +.PHONY: lint style black test test_ci spell copyright html doctest clean_sphinx coverage clean -all_check: spell style lint copyright +all_check: spell style lint copyright clean_sphinx html doctest lint: pylint -rn qiskit_algorithms test tools @@ -58,10 +58,20 @@ test_ci: spell: pylint -rn --disable=all --enable=spelling --spelling-dict=en_US --spelling-private-dict-file=.pylintdict qiskit_algorithms test tools + sphinx-build -M spelling docs docs/_build -W -T --keep-going $(SPHINXOPTS) copyright: python tools/check_copyright.py +html: + sphinx-build -M html docs docs/_build -W -T --keep-going $(SPHINXOPTS) + +doctest: + sphinx-build -M doctest docs docs/_build -W -T --keep-going $(SPHINXOPTS) + +clean_sphinx: + make -C docs clean + coverage: coverage3 run --source qiskit_algorithms -m unittest discover -s test -q coverage3 report From 4e5ea25ba71dc4466f677a45b12d6a991c1c49cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 11:50:41 +0200 Subject: [PATCH 08/31] Add config to tox --- tox.ini | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tox.ini b/tox.ini index 2c2f6408..d9a681f5 100644 --- a/tox.ini +++ b/tox.ini @@ -43,3 +43,30 @@ commands = stestr run {posargs} coverage3 combine coverage3 report + +[testenv:docs] +envdir = .tox/docs +basepython = python3 +commands = + sphinx-build -j auto -W -T --keep-going -b html {posargs} docs/ docs/_build/html + +[testenv:docs-clean] +skip_install = true +deps = +allowlist_externals = rm +commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build + +[testenv:gettext] +envdir = .tox/docs +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements-dev.txt + torch + sparse + torchvision + sphinx-intl + jupyter +commands = + pip install -e . + sphinx-build -W -T --keep-going -b gettext docs/ docs/_build/gettext {posargs} + sphinx-intl -c docs/conf.py update -p docs/_build/gettext -l en -d docs/locale From ac0b99e3094c4cd3a6f0842c3d26f8352fb7a12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 11:59:30 +0200 Subject: [PATCH 09/31] Update workflows --- .github/workflows/deploy-docs.yml | 86 +++++++++++++++++++++++++++++++ .github/workflows/main.yml | 71 +++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 .github/workflows/deploy-docs.yml diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..85fbdeff --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,86 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2021, 2022. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +name: Deploy Docs + +on: + workflow_dispatch: + +concurrency: + group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + docs_publish: + if: ${{ startsWith(github.ref, 'refs/heads/stable') && contains('["t-imamichi","mtreinish","stefan-woerner","woodsp-ibm"]', github.actor) }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: [3.8] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - uses: ./.github/actions/install-optimization + with: + os: ${{ matrix.os }} + - name: Install Dependencies + run: | + pip install jupyter qiskit-terra[visualization] + sudo apt-get install -y pandoc graphviz + shell: bash + - name: Build and publish + env: + encrypted_rclone_key: ${{ secrets.encrypted_rclone_key }} + encrypted_rclone_iv: ${{ secrets.encrypted_rclone_iv }} + QISKIT_PARALLEL: False + QISKIT_DOCS_BUILD_TUTORIALS: 'always' + run: | + echo "earliest_version: 0.1.0" >> releasenotes/config.yaml + tools/ignore_untagged_notes.sh + make html + tools/deploy_documentation.sh + shell: bash + deploy-translatable-strings: + if: ${{ startsWith(github.ref, 'refs/heads/stable') && contains('["t-imamichi","mtreinish","stefan-woerner","woodsp-ibm"]', github.actor) }} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install jupyter qiskit-terra[visualization] torchvision tox + sudo apt-get install -y pandoc graphviz + shell: bash + - name: Build and publish + env: + encrypted_deploy_po_branch_key: ${{ secrets.encrypted_deploy_po_branch_key }} + encrypted_deploy_po_branch_iv: ${{ secrets.encrypted_deploy_po_branch_iv }} + QISKIT_PARALLEL: False + QISKIT_DOCS_BUILD_TUTORIALS: 'always' + run: | + echo "earliest_version: 0.1.0" >> releasenotes/config.yaml + tools/ignore_untagged_notes.sh + tools/deploy_translatable_strings.sh + shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a578bcb0..1f9115c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,11 +71,34 @@ jobs: - run: pip check if: ${{ !cancelled() }} shell: bash + - name: Copyright Check + run: | + python tools/check_copyright.py -check + if: ${{ !cancelled() }} + shell: bash - name: Style Check run: | make style if: ${{ !cancelled() }} shell: bash + - name: Run make html + run: | + make clean_sphinx + make html + cd docs/_build/html + mkdir artifacts + tar -zcvf artifacts/documentation.tar.gz --exclude=./artifacts . + if: ${{ !cancelled() }} + shell: bash + - name: Run upload documentation + uses: actions/upload-artifact@v3 + with: + name: documentation + path: docs/_build/html/artifacts/documentation.tar.gz + if: ${{ !cancelled() }} + - run: make doctest + if: ${{ !cancelled() }} + shell: bash Algorithms: runs-on: ${{ matrix.os }} strategy: @@ -129,6 +152,54 @@ jobs: with: name: ${{ matrix.os }}-${{ matrix.python-version }} path: ./ci-artifact-data/* + Tutorials: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + python-version: [ 3.7, 3.8 ] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + setup.py + requirements.txt + requirements-dev.txt + - uses: ./.github/actions/install-main-dependencies + with: + os: ${{ matrix.os }} + python-version: ${{ matrix.python-version }} + if: ${{ !startsWith(github.ref, 'refs/heads/stable') && !startsWith(github.base_ref, 'stable/') }} + - uses: ./.github/actions/install-algorithms + with: + os: ${{ matrix.os }} + - name: Install Dependencies + run: | + pip install jupyter qiskit-terra[visualization] + sudo apt-get install -y pandoc graphviz + shell: bash + - name: Run Qiskit Algorithms Tutorials + env: + QISKIT_PARALLEL: False + QISKIT_DOCS_BUILD_TUTORIALS: 'always' + run: | + echo "earliest_version: 0.1.0" >> releasenotes/config.yaml + make html + cd docs/_build/html + mkdir artifacts + tar -zcvf artifacts/tutorials.tar.gz --exclude=./artifacts . + shell: bash + - name: Run upload tutorials + uses: actions/upload-artifact@v3 + with: + name: tutorials${{ matrix.python-version }} + path: docs/_build/html/artifacts/tutorials.tar.gz Deprecation_Messages_and_Coverage: needs: [Checks, Algorithms] runs-on: ubuntu-latest From 9fa5dbcdf40d626377d378457ae2f7773bc52475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 12:01:51 +0200 Subject: [PATCH 10/31] Bump tutorials python --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f9115c3..72baae11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -158,7 +158,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - python-version: [ 3.7, 3.8 ] + python-version: [ 3.8, 3.9 ] steps: - uses: actions/checkout@v3 with: From 5242b34b440f266a0c5d5b7401b6e0b93effb7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 13:02:20 +0200 Subject: [PATCH 11/31] Update deploy docs --- .github/workflows/deploy-docs.yml | 32 +------------------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 85fbdeff..33dd6b40 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -21,7 +21,7 @@ concurrency: jobs: docs_publish: - if: ${{ startsWith(github.ref, 'refs/heads/stable') && contains('["t-imamichi","mtreinish","stefan-woerner","woodsp-ibm"]', github.actor) }} + if: ${{ startsWith(github.ref, 'refs/heads/stable') && contains('["mtreinish","Cryoris","ElePT","woodsp-ibm"]', github.actor) }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -54,33 +54,3 @@ jobs: make html tools/deploy_documentation.sh shell: bash - deploy-translatable-strings: - if: ${{ startsWith(github.ref, 'refs/heads/stable') && contains('["t-imamichi","mtreinish","stefan-woerner","woodsp-ibm"]', github.actor) }} - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.8] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install jupyter qiskit-terra[visualization] torchvision tox - sudo apt-get install -y pandoc graphviz - shell: bash - - name: Build and publish - env: - encrypted_deploy_po_branch_key: ${{ secrets.encrypted_deploy_po_branch_key }} - encrypted_deploy_po_branch_iv: ${{ secrets.encrypted_deploy_po_branch_iv }} - QISKIT_PARALLEL: False - QISKIT_DOCS_BUILD_TUTORIALS: 'always' - run: | - echo "earliest_version: 0.1.0" >> releasenotes/config.yaml - tools/ignore_untagged_notes.sh - tools/deploy_translatable_strings.sh - shell: bash From 987c15e121c67238f5381b5e808d5c0eb444c9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 13:14:44 +0200 Subject: [PATCH 12/31] Add docs deploy to tools --- tools/deploy_documentation.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tools/deploy_documentation.sh diff --git a/tools/deploy_documentation.sh b/tools/deploy_documentation.sh new file mode 100644 index 00000000..97eb2358 --- /dev/null +++ b/tools/deploy_documentation.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This code is part of Qiskit. +# +# (C) Copyright IBM 2018, 2023. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +# Script for pushing the documentation to qiskit.org/ecosystem. +set -e + +curl https://downloads.rclone.org/rclone-current-linux-amd64.deb -o rclone.deb +sudo apt-get install -y ./rclone.deb + +RCLONE_CONFIG_PATH=$(rclone config file | tail -1) + +echo "show current dir: " +pwd + +# Push to qiskit.org/ecosystem +openssl aes-256-cbc -K $encrypted_rclone_key -iv $encrypted_rclone_iv -in tools/rclone.conf.enc -out $RCLONE_CONFIG_PATH -d +echo "Pushing built docs to qiskit.org/ecosystem" +rclone sync --progress --exclude locale/** ./docs/_build/html IBMCOS:qiskit-org-web-resources/ecosystem/algorithms From bd2c87e6988cd56f521a9f37aabaa6b876b17b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 13:19:13 +0200 Subject: [PATCH 13/31] Add ignore untagged --- .github/workflows/main.yml | 3 ++- tools/ignore_untagged_notes.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) mode change 100755 => 100644 tools/ignore_untagged_notes.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72baae11..79ed4ee8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -158,7 +158,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - python-version: [ 3.8, 3.9 ] + python-version: [ 3.8, 3.11 ] steps: - uses: actions/checkout@v3 with: @@ -190,6 +190,7 @@ jobs: QISKIT_DOCS_BUILD_TUTORIALS: 'always' run: | echo "earliest_version: 0.1.0" >> releasenotes/config.yaml + tools/ignore_untagged_notes.sh make html cd docs/_build/html mkdir artifacts diff --git a/tools/ignore_untagged_notes.sh b/tools/ignore_untagged_notes.sh old mode 100755 new mode 100644 index ad7d5a03..b31071b0 --- a/tools/ignore_untagged_notes.sh +++ b/tools/ignore_untagged_notes.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This code is part of a Qiskit project. +# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2023. # From 2433d2785645f44979e76feb085cece85ae5095d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:48:54 +0200 Subject: [PATCH 14/31] Apply suggestions from Eric's code review Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> --- docs/conf.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 4c1a4940..2c7b87f3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,14 +80,9 @@ # -- Options for HTML output ------------------------------------------------- -html_theme = "qiskit_sphinx_theme" +html_theme = "qiskit-ecosystem" html_last_updated_fmt = "%Y/%m/%d" -html_theme_options = { - "logo_only": True, - "display_version": True, - "prev_next_buttons_location": "bottom", - "style_external_links": True, -} +html_title = f"{project} {release}" # -- Options for Autosummary and Autodoc ------------------------------------- From bee2d0ceb3e39df10ce977d0a499c460e40c6347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:54:35 +0200 Subject: [PATCH 15/31] Apply suggestions from Eric's code review Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index c4ed8a52..5f9219e3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,7 +10,7 @@ seaborn>=0.9.0 reno>=3.4.0 Sphinx>=5.0 nbsphinx -qiskit-sphinx-theme>=1.11.0 +qiskit-sphinx-theme~=1.14.0rc1 sphinx-design>=0.2.0 sphinxcontrib-spelling jupyter-sphinx From cefe5b18be5545f90a9bf3e9bd469cba0ead2c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 16:56:55 +0200 Subject: [PATCH 16/31] Apply suggestions from code review --- docs/conf.py | 11 ++--------- requirements-dev.txt | 1 - tox.ini | 15 --------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 4c1a4940..761ac3bc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,7 +45,8 @@ "reno.sphinxext", "sphinx_design", "matplotlib.sphinxext.plot_directive", - "sphinx.ext.doctest" + "sphinx.ext.doctest", + "qiskit_sphinx_theme" ] templates_path = ["_templates"] @@ -70,14 +71,6 @@ # (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F). modindex_common_prefix = ["qiskit."] -intersphinx_mapping = { - "rustworkx": ("https://qiskit.org/ecosystem/rustworkx/", None), - "qiskit-ibm-runtime": ("https://qiskit.org/ecosystem/ibm-runtime/", None), - "qiskit-aer": ("https://qiskit.org/ecosystem/aer/", None), - "numpy": ("https://numpy.org/doc/stable/", None), - "matplotlib": ("https://matplotlib.org/stable/", None), -} - # -- Options for HTML output ------------------------------------------------- html_theme = "qiskit_sphinx_theme" diff --git a/requirements-dev.txt b/requirements-dev.txt index c4ed8a52..01974acb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -15,5 +15,4 @@ sphinx-design>=0.2.0 sphinxcontrib-spelling jupyter-sphinx discover -docplex rustworkx>=0.13 diff --git a/tox.ini b/tox.ini index d9a681f5..e86634ce 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,6 @@ commands = coverage3 report [testenv:docs] -envdir = .tox/docs basepython = python3 commands = sphinx-build -j auto -W -T --keep-going -b html {posargs} docs/ docs/_build/html @@ -56,17 +55,3 @@ deps = allowlist_externals = rm commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build -[testenv:gettext] -envdir = .tox/docs -deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt - torch - sparse - torchvision - sphinx-intl - jupyter -commands = - pip install -e . - sphinx-build -W -T --keep-going -b gettext docs/ docs/_build/gettext {posargs} - sphinx-intl -c docs/conf.py update -p docs/_build/gettext -l en -d docs/locale From 3c749536e7a6594777ba74c58151202b93cf0f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 18:10:37 +0200 Subject: [PATCH 17/31] Add nbsphinx to config --- docs/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index c70b16c9..0c15bd5c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,8 @@ "sphinx_design", "matplotlib.sphinxext.plot_directive", "sphinx.ext.doctest", - "qiskit_sphinx_theme" + "qiskit_sphinx_theme", + "nbsphinx" ] templates_path = ["_templates"] From af620dd564827fece0294ace76abfd8d2dd5c5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 18:14:16 +0200 Subject: [PATCH 18/31] Add executable attribute --- tools/deploy_documentation.sh | 0 tools/ignore_untagged_notes.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/deploy_documentation.sh mode change 100644 => 100755 tools/ignore_untagged_notes.sh diff --git a/tools/deploy_documentation.sh b/tools/deploy_documentation.sh old mode 100644 new mode 100755 diff --git a/tools/ignore_untagged_notes.sh b/tools/ignore_untagged_notes.sh old mode 100644 new mode 100755 From 684e4be7701a6494a5a8bb541639a538bf5ba6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:19:19 +0200 Subject: [PATCH 19/31] Fix headers Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> --- .github/workflows/deploy-docs.yml | 4 ++-- docs/conf.py | 4 ++-- tools/deploy_documentation.sh | 4 ++-- tools/ignore_untagged_notes.sh | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 33dd6b40..eba5c214 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,6 +1,6 @@ -# This code is part of Qiskit. +# This code is part of a Qiskit project. # -# (C) Copyright IBM 2021, 2022. +# (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/docs/conf.py b/docs/conf.py index 0c15bd5c..4add1c30 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,6 @@ -# This code is part of Qiskit. +# This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/tools/deploy_documentation.sh b/tools/deploy_documentation.sh index 97eb2358..d555c715 100755 --- a/tools/deploy_documentation.sh +++ b/tools/deploy_documentation.sh @@ -1,8 +1,8 @@ #!/bin/bash -# This code is part of Qiskit. +# This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/tools/ignore_untagged_notes.sh b/tools/ignore_untagged_notes.sh index b31071b0..ad7d5a03 100755 --- a/tools/ignore_untagged_notes.sh +++ b/tools/ignore_untagged_notes.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This code is part of Qiskit. +# This code is part of a Qiskit project. # # (C) Copyright IBM 2021, 2023. # From 71e36506c7623b8e514851dd383ada9cfea3d559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 18:23:24 +0200 Subject: [PATCH 20/31] Update reqs --- requirements-dev.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 71866bfd..5fc2ab19 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,12 +6,10 @@ pylint>=2.15.0 stestr>=2.0.0 pylatexenc>=1.4 ddt>=1.2.0,!=1.4.0,!=1.4.3 -seaborn>=0.9.0 reno>=3.4.0 Sphinx>=5.0 nbsphinx qiskit-sphinx-theme~=1.14.0rc1 -sphinx-design>=0.2.0 sphinxcontrib-spelling jupyter-sphinx discover From 0c985c5d15daebe2be48e155628b1328c2456b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 18:48:10 +0200 Subject: [PATCH 21/31] Remove earliest version --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79ed4ee8..c0e28d98 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,7 +66,6 @@ jobs: run: | sudo apt-get -y install pandoc graphviz python3-enchant hunspell-en-us pip install pyenchant - echo "earliest_version: 0.1.0" >> releasenotes/config.yaml shell: bash - run: pip check if: ${{ !cancelled() }} @@ -189,7 +188,6 @@ jobs: QISKIT_PARALLEL: False QISKIT_DOCS_BUILD_TUTORIALS: 'always' run: | - echo "earliest_version: 0.1.0" >> releasenotes/config.yaml tools/ignore_untagged_notes.sh make html cd docs/_build/html From 546ee0977d92dd5ad83829a83010ec7d2bf4a3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Mon, 24 Jul 2023 18:51:46 +0200 Subject: [PATCH 22/31] Update reqs --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 5fc2ab19..f8c068a4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,6 +10,7 @@ reno>=3.4.0 Sphinx>=5.0 nbsphinx qiskit-sphinx-theme~=1.14.0rc1 +sphinx-design>=0.2.0 sphinxcontrib-spelling jupyter-sphinx discover From 9892b71ba93580c24d768900edcd3a3b6161ac7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Tue, 25 Jul 2023 10:16:47 +0200 Subject: [PATCH 23/31] Add nbsphinx config --- docs/conf.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 4add1c30..b5de21dc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,6 +50,39 @@ "nbsphinx" ] +rst_prolog = """ +.. raw:: html + +


+ +.. |version| replace:: {0} +""".format( + release +) + +nbsphinx_prolog = """ +{% set docname = env.doc2path(env.docname, base=None) %} +.. only:: html + + .. role:: raw-html(raw) + :format: html + + .. note:: + This page was generated from `docs/{{ docname }}`__. + + __""" + +vers = version.split(".") +link_str = f" https://github.com/qiskit-community/qiskit-algorithms/blob/stable/{vers[0]}.{vers[1]}/docs/" +nbsphinx_prolog += link_str + "{{ docname }}" + +nbsphinx_timeout = 360 +nbsphinx_execute = os.getenv("QISKIT_DOCS_BUILD_TUTORIALS", "never") +nbsphinx_widgets_path = "" +nbsphinx_thumbnails = { + "**": "_static/images/logo.png", +} + templates_path = ["_templates"] # Number figures, tables and code-blocks if they have a caption. From 9ed17ea6d518882012dbfd82483ee8cbb720c823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Tue, 25 Jul 2023 10:45:21 +0200 Subject: [PATCH 24/31] Remove OptimizerSupportLevel --- qiskit_algorithms/optimizers/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qiskit_algorithms/optimizers/__init__.py b/qiskit_algorithms/optimizers/__init__.py index b40144c9..942de206 100644 --- a/qiskit_algorithms/optimizers/__init__.py +++ b/qiskit_algorithms/optimizers/__init__.py @@ -35,7 +35,6 @@ :nosignatures: OptimizerResult - OptimizerSupportLevel Optimizer Minimizer From 8cdda77eeb9cf935fc35e9b4ef8aecefa8641f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Tue, 25 Jul 2023 17:29:47 +0200 Subject: [PATCH 25/31] Add index and getting started page --- docs/getting_started.rst | 115 +++++++++++++++++++++++++++++++++++++++ docs/index.rst | 16 ++++++ 2 files changed, 131 insertions(+) create mode 100644 docs/getting_started.rst diff --git a/docs/getting_started.rst b/docs/getting_started.rst new file mode 100644 index 00000000..d5320964 --- /dev/null +++ b/docs/getting_started.rst @@ -0,0 +1,115 @@ +:orphan: + +############### +Getting started +############### + +Installation +============ + +Qiskit Algorithms depends on the main Qiskit package which has its own +`Qiskit Getting Started `__ detailing the +installation options for Qiskit and its supported environments/platforms. You should refer to +that first, before focusing on the additional installation instructions +specific to Qiskit Algorithms. + +Qiskit Algorithms has some functions that have been made optional where the dependent code and/or +support program(s) are not (or cannot be) installed by default. +See :ref:`optional_installs` for more information. + +.. tab-set:: + + .. tab-item:: Start locally + + The simplest way to get started is to use the pip package manager: + + .. code:: sh + + pip install qiskit-algorithms + + .. tab-item:: Install from source + + Installing Qiskit Algorithms from source allows you to access the most recently + updated version under development, instead of using the version in the Python Package + Index (PyPI) repository. + + Since Qiskit Algorithms depends on Qiskit, and its latest changes may require new or changed + features of Qiskit, you should first follow Qiskit's `"Install from source"` instructions + here `Qiskit Getting Started `__ + + .. raw:: html + +

Installing Qiskit Algorithms from Source

+ + Using the same development environment that you installed Qiskit in you are ready to install + Qiskit Algorithms. + + 1. Clone the Qiskit Algorithms repository. + + .. code:: sh + + git clone https://github.com/qiskit-community/qiskit-algorithms.git + + 2. Cloning the repository creates a local folder called ``qiskit-algorithms``. + + .. code:: sh + + cd qiskit-algorithms + + 3. If you want to run tests or linting checks, install the developer requirements. + + .. code:: sh + + pip install -r requirements-dev.txt + + 4. Install ``qiskit-algorithms``. + + .. code:: sh + + pip install . + + If you want to install it in editable mode, meaning that code changes to the + project don't require a reinstall to be applied, you can do this with: + + .. code:: sh + + pip install -e . + + +.. _optional_installs: + +Optional installs +================= + +Some optimization algorithms require specific libraries to be run: + +* **Scikit-quant**, may be installed using the command `pip install scikit-quant`. + +* **SnobFit**, may be installed using the command `pip install SQSnobFit`. + +* **NLOpt**, may be installed using the command `pip install nlopt`. + + +Ready to get going?... +====================== + +.. raw:: html + +
+
+ +.. qiskit-call-to-action-item:: + :description: Find out about Qiskit Algorithms. + :header: Dive into the tutorials + :button_link: ./tutorials/index.html + :button_text: Qiskit Algorithms tutorials + +.. raw:: html + +
+
+ + +.. Hiding - Indices and tables + :ref:`genindex` + :ref:`modindex` diff --git a/docs/index.rst b/docs/index.rst index b48b7e35..c8df8f37 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,6 +2,22 @@ Qiskit Algorithms documentation ################################ +Overview +======== + +Qiskit Algorithms is a library of quantum algorithms based on Qiskit, +suitable to run on near-term quantum devices with short-depth circuits. + + +Next Steps +=========== + +`Getting started `_ + +`Tutorials `_ + + +.. currentmodule:: qiskit_algorithms .. toctree:: :hidden: From 128a0c4224648a3dbd1733bd4d7be51a367ee260 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Tue, 25 Jul 2023 16:11:24 -0400 Subject: [PATCH 26/31] Fix release note and add intersphinx mappings --- docs/conf.py | 7 ++++++ ...algrithms-from-terra-6a8aa994d1206806.yaml | 24 ++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b5de21dc..469e7c9d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -105,6 +105,13 @@ # (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F). modindex_common_prefix = ["qiskit."] +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "numpy": ("https://numpy.org/doc/stable", None), + "scipy": ("https://docs.scipy.org/doc/scipy", None), + "qiskit": ("https://qiskit.org/documentation/", None), +} + # -- Options for HTML output ------------------------------------------------- html_theme = "qiskit-ecosystem" diff --git a/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml b/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml index 0cefe6b9..af4e214b 100644 --- a/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml +++ b/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml @@ -1,17 +1,23 @@ --- -prelude: - - | +prelude: | Qiskit's `qiskit.algorithms` module has been superseded by this new standalone library, ``qiskit_algorithms``. + As of Qiskit's 0.25 release, active development of new algorithm features has moved to this new package. + If you're relying on :mod:`qiskit.algorithms` you should update your requirements to also include ``qiskit-algorithms`` and update the imports - from ``qiskit.algorithms`` to ``qiskit_algorithms``. If you have not yet - migrated from ``QuantumInstance``-based to primitives-based algorithms, - you should follow the migration guidelines in https://qisk.it/algo_migration, - to complete the migration of your code, as this package does not include - any deprecated algorithm function. - The decision to migrate the :mod:`~.algorithms` module to a - separate package was made to clarify the purpose of Qiskit and + from ``qiskit.algorithms`` to ``qiskit_algorithms``. + + .. note:: + + If you have not yet + migrated from ``QuantumInstance``-based to primitives-based algorithms, + you should first follow the migration guidelines in https://qisk.it/algo_migration, + to complete the migration of your code, as this package does not include + any deprecated algorithm function. + + The decision to migrate the :mod:`qiskit.algorithms` module to a + separate package was made to clarify the purpose of `Qiskit `_ and make a distinction between the tools and libraries built on top of it. From 9958d7a28eab89616c93ab75a63c35050d2ea698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Wed, 26 Jul 2023 17:43:15 +0200 Subject: [PATCH 27/31] Apply suggestions from code review --- docs/getting_started.rst | 21 ++++++--------------- docs/index.rst | 2 ++ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index d5320964..749588d5 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -93,22 +93,13 @@ Some optimization algorithms require specific libraries to be run: Ready to get going?... ====================== -.. raw:: html - -
-
- -.. qiskit-call-to-action-item:: - :description: Find out about Qiskit Algorithms. - :header: Dive into the tutorials - :button_link: ./tutorials/index.html - :button_text: Qiskit Algorithms tutorials - -.. raw:: html - -
-
+.. qiskit-call-to-action-grid:: + .. qiskit-call-to-action-item:: + :description: Find out about Qiskit Algorithms. + :header: Dive into the tutorials + :button_link: ./tutorials/index.html + :button_text: Qiskit Algorithms tutorials .. Hiding - Indices and tables :ref:`genindex` diff --git a/docs/index.rst b/docs/index.rst index c8df8f37..aad34a14 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,6 +22,8 @@ Next Steps .. toctree:: :hidden: + Overview + Getting Started API References Tutorials Release Notes From 385a5bd97f940f47969e7052df80e12409c7c38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Tue, 25 Jul 2023 17:39:12 +0200 Subject: [PATCH 28/31] Add first release note (#19) Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> --- ...e-algrithms-from-terra-6a8aa994d1206806.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml diff --git a/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml b/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml new file mode 100644 index 00000000..0cefe6b9 --- /dev/null +++ b/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml @@ -0,0 +1,17 @@ +--- +prelude: + - | + Qiskit's `qiskit.algorithms` module has been superseded by this + new standalone library, ``qiskit_algorithms``. + As of Qiskit's 0.25 release, active development of new + algorithm features has moved to this new package. + If you're relying on :mod:`qiskit.algorithms` you should update your + requirements to also include ``qiskit-algorithms`` and update the imports + from ``qiskit.algorithms`` to ``qiskit_algorithms``. If you have not yet + migrated from ``QuantumInstance``-based to primitives-based algorithms, + you should follow the migration guidelines in https://qisk.it/algo_migration, + to complete the migration of your code, as this package does not include + any deprecated algorithm function. + The decision to migrate the :mod:`~.algorithms` module to a + separate package was made to clarify the purpose of Qiskit and + make a distinction between the tools and libraries built on top of it. From e33ddfbd6a47483cd41b1d0d9bed771ce82ae75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <57907331+ElePT@users.noreply.github.com> Date: Tue, 25 Jul 2023 19:29:37 +0200 Subject: [PATCH 29/31] Remove deprecated logic from algorithms (#18) Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> --- qiskit_algorithms/optimizers/adam_amsgrad.py | 16 +-------- qiskit_algorithms/optimizers/spsa.py | 36 ------------------- .../phase_estimation_result.py | 15 -------- test/optimizers/test_spsa.py | 6 ++-- 4 files changed, 4 insertions(+), 69 deletions(-) diff --git a/qiskit_algorithms/optimizers/adam_amsgrad.py b/qiskit_algorithms/optimizers/adam_amsgrad.py index 6deb5c0f..9a986712 100644 --- a/qiskit_algorithms/optimizers/adam_amsgrad.py +++ b/qiskit_algorithms/optimizers/adam_amsgrad.py @@ -19,7 +19,6 @@ import csv import numpy as np -from qiskit.utils.deprecation import deprecate_arg from .optimizer import Optimizer, OptimizerSupportLevel, OptimizerResult, POINT # pylint: disable=invalid-name @@ -198,21 +197,13 @@ def load_params(self, load_dir: str) -> None: t = t[1:-1] self._t = np.fromstring(t, dtype=int, sep=" ") - @deprecate_arg("objective_function", new_alias="fun", since="0.19.0") - @deprecate_arg("initial_point", new_alias="fun", since="0.19.0") - @deprecate_arg("gradient_function", new_alias="jac", since="0.19.0") def minimize( self, fun: Callable[[POINT], float], x0: POINT, jac: Callable[[POINT], POINT] | None = None, bounds: list[tuple[float, float]] | None = None, - # pylint:disable=unused-argument - objective_function: Callable[[np.ndarray], float] | None = None, - initial_point: np.ndarray | None = None, - gradient_function: Callable[[np.ndarray], float] | None = None, - # ) -> Tuple[np.ndarray, float, int]: - ) -> OptimizerResult: # TODO find proper way to deprecate return type + ) -> OptimizerResult: """Minimize the scalar function. Args: @@ -221,11 +212,6 @@ def minimize( jac: The gradient of the scalar function ``fun``. bounds: Bounds for the variables of ``fun``. This argument might be ignored if the optimizer does not support bounds. - objective_function: DEPRECATED. A function handle to the objective function. - initial_point: DEPRECATED. The initial iteration point. - gradient_function: DEPRECATED. A function handle to the gradient of the objective - function. - Returns: The result of the optimization, containing e.g. the result as attribute ``x``. """ diff --git a/qiskit_algorithms/optimizers/spsa.py b/qiskit_algorithms/optimizers/spsa.py index 562e0656..a7944733 100644 --- a/qiskit_algorithms/optimizers/spsa.py +++ b/qiskit_algorithms/optimizers/spsa.py @@ -27,7 +27,6 @@ import numpy as np from qiskit.utils import algorithm_globals -from qiskit.utils.deprecation import deprecate_func from .optimizer import Optimizer, OptimizerSupportLevel, OptimizerResult, POINT @@ -648,41 +647,6 @@ def get_support_level(self): "initial_point": OptimizerSupportLevel.required, } - # pylint: disable=bad-docstring-quotes - @deprecate_func( - additional_msg=( - "Instead, use ``SPSA.minimize`` as a replacement, which supports the same arguments " - "but follows the interface of scipy.optimize and returns a complete result object " - "containing additional information." - ), - since="0.21.0", - ) - def optimize( - self, - num_vars, # pylint: disable=unused-argument - objective_function, - gradient_function=None, # pylint: disable=unused-argument - variable_bounds=None, # pylint: disable=unused-argument - initial_point=None, - ): - """Perform optimization. - - Args: - num_vars (int): Number of parameters to be optimized. - objective_function (callable): A function that computes the objective function. - gradient_function (callable): Not supported for SPSA. - variable_bounds (list[(float, float)]): Not supported for SPSA. - initial_point (numpy.ndarray[float]): Initial point. - - Returns: - tuple: point, value, nfev - point: is a 1D numpy.ndarray[float] containing the solution - value: is a float with the objective function value - nfev: number of objective function calls made if available or None - """ - result = self.minimize(objective_function, initial_point) - return result.x, result.fun, result.nfev - def bernoulli_perturbation(dim, perturbation_dims=None): """Get a Bernoulli random perturbation.""" diff --git a/qiskit_algorithms/phase_estimators/phase_estimation_result.py b/qiskit_algorithms/phase_estimators/phase_estimation_result.py index 83b5c347..5712c273 100644 --- a/qiskit_algorithms/phase_estimators/phase_estimation_result.py +++ b/qiskit_algorithms/phase_estimators/phase_estimation_result.py @@ -14,7 +14,6 @@ from __future__ import annotations import numpy -from qiskit.utils.deprecation import deprecate_func from qiskit.result import Result from .phase_estimator import PhaseEstimatorResult @@ -66,20 +65,6 @@ def circuit_result(self) -> Result: """ return self._circuit_result - @property - @deprecate_func( - additional_msg="Instead, use the property ``phase``, which behaves the same.", - since="0.18.0", - is_property=True, - ) - def most_likely_phase(self) -> float: - r"""DEPRECATED - Return the most likely phase as a number in :math:`[0.0, 1.0)`. - - 1.0 corresponds to a phase of :math:`2\pi`. This selects the phase corresponding - to the bit string with the highesest probability. This is the most likely phase. - """ - return self.phase - @property def phase(self) -> float: r"""Return the most likely phase as a number in :math:`[0.0, 1.0)`. diff --git a/test/optimizers/test_spsa.py b/test/optimizers/test_spsa.py index 00500501..99f26848 100644 --- a/test/optimizers/test_spsa.py +++ b/test/optimizers/test_spsa.py @@ -74,13 +74,13 @@ def objective(x): spsa = SPSA(**settings) with self.assertWarns(DeprecationWarning): - result = spsa.optimize(circuit.num_parameters, objective, initial_point=initial_point) + result = spsa.minimize(objective, x0=initial_point) with self.subTest("check final accuracy"): - self.assertLess(result[1], -0.95) # final loss + self.assertLess(result.fun, -0.95) # final loss with self.subTest("check number of function calls"): - self.assertEqual(result[2], expected_nfev) # function evaluations + self.assertEqual(result.nfev, expected_nfev) # function evaluations def test_recalibrate_at_optimize(self): """Test SPSA calibrates anew upon each optimization run, if no autocalibration is set.""" From 6d797ba66dca72e5aa738f51b57d1a841be4c2e3 Mon Sep 17 00:00:00 2001 From: woodsp-ibm Date: Tue, 25 Jul 2023 16:11:24 -0400 Subject: [PATCH 30/31] Fix release note and add intersphinx mappings --- docs/conf.py | 7 ++++++ ...algrithms-from-terra-6a8aa994d1206806.yaml | 24 ++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b5de21dc..469e7c9d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -105,6 +105,13 @@ # (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F). modindex_common_prefix = ["qiskit."] +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "numpy": ("https://numpy.org/doc/stable", None), + "scipy": ("https://docs.scipy.org/doc/scipy", None), + "qiskit": ("https://qiskit.org/documentation/", None), +} + # -- Options for HTML output ------------------------------------------------- html_theme = "qiskit-ecosystem" diff --git a/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml b/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml index 0cefe6b9..af4e214b 100644 --- a/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml +++ b/releasenotes/notes/migrate-algrithms-from-terra-6a8aa994d1206806.yaml @@ -1,17 +1,23 @@ --- -prelude: - - | +prelude: | Qiskit's `qiskit.algorithms` module has been superseded by this new standalone library, ``qiskit_algorithms``. + As of Qiskit's 0.25 release, active development of new algorithm features has moved to this new package. + If you're relying on :mod:`qiskit.algorithms` you should update your requirements to also include ``qiskit-algorithms`` and update the imports - from ``qiskit.algorithms`` to ``qiskit_algorithms``. If you have not yet - migrated from ``QuantumInstance``-based to primitives-based algorithms, - you should follow the migration guidelines in https://qisk.it/algo_migration, - to complete the migration of your code, as this package does not include - any deprecated algorithm function. - The decision to migrate the :mod:`~.algorithms` module to a - separate package was made to clarify the purpose of Qiskit and + from ``qiskit.algorithms`` to ``qiskit_algorithms``. + + .. note:: + + If you have not yet + migrated from ``QuantumInstance``-based to primitives-based algorithms, + you should first follow the migration guidelines in https://qisk.it/algo_migration, + to complete the migration of your code, as this package does not include + any deprecated algorithm function. + + The decision to migrate the :mod:`qiskit.algorithms` module to a + separate package was made to clarify the purpose of `Qiskit `_ and make a distinction between the tools and libraries built on top of it. From 8e4f83fe3ae9fb8242d362a1fab66c7c42e42941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Wed, 26 Jul 2023 18:00:44 +0200 Subject: [PATCH 31/31] Add manual CSS config --- docs/_static/nbsphinx-gallery.css | 31 +++++++++++++++++++++++++++++++ docs/conf.py | 7 +++++++ 2 files changed, 38 insertions(+) create mode 100644 docs/_static/nbsphinx-gallery.css diff --git a/docs/_static/nbsphinx-gallery.css b/docs/_static/nbsphinx-gallery.css new file mode 100644 index 00000000..f60c7b59 --- /dev/null +++ b/docs/_static/nbsphinx-gallery.css @@ -0,0 +1,31 @@ +.nbsphinx-gallery { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); + gap: 5px; + margin-top: 1em; + margin-bottom: 1em; +} + +.nbsphinx-gallery>a { + padding: 5px; + border: 1px dotted currentColor; + border-radius: 2px; + text-align: center; +} + +.nbsphinx-gallery>a:hover { + border-style: solid; +} + +.nbsphinx-gallery img { + max-width: 100%; + max-height: 100%; +} + +.nbsphinx-gallery>a>div:first-child { + display: flex; + align-items: start; + justify-content: center; + height: 120px; + margin-bottom: 5px; +} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 469e7c9d..88ce2f0f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,6 +33,12 @@ # The full version, including alpha/beta/rc tags release = "0.1.0" +# Manually add the gallery CSS file for now +# TODO: Figure out why the styling is not working by default +html_css_files = [ + "nbsphinx-gallery.css", +] + extensions = [ "sphinx.ext.napoleon", "sphinx.ext.autodoc", @@ -151,3 +157,4 @@ # >> code # output doctest_test_doctest_blocks = "" +