Skip to content

Commit

Permalink
Merge branch 'main' into controlflow/commutative_cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapeyre authored Jul 12, 2023
2 parents 074fb21 + e2674ce commit 433ac38
Show file tree
Hide file tree
Showing 335 changed files with 4,063 additions and 1,058 deletions.
40 changes: 39 additions & 1 deletion .azure/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ jobs:
image_tests/bin/python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
-e ".[visualization]"
sudo apt-get update
sudo apt-get install -y graphviz pandoc
Expand All @@ -185,10 +186,47 @@ jobs:
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
- bash: image_tests/bin/python -m unittest discover -v test/ipynb
- bash: image_tests/bin/python -m unittest discover -v test/visual
displayName: 'Run image test'
env:
# Needed to suppress a warning in jupyter-core 5.x by eagerly migrating to
# a new internal interface that will be the default in jupyter-core 6.x.
# This variable should become redundant on release of jupyter-core 6.
JUPYTER_PLATFORM_DIRS: 1

- task: ArchiveFiles@2
displayName: Archive visual test failure diffs
inputs:
rootFolderOrFile: 'test/visual/mpl/visual_test_failures'
includeRootFolder: false
archiveType: tar
archiveFile: '$(Build.ArtifactStagingDirectory)/visual_test_failures.tar.gz'
verbose: true
condition: failed()

- task: ArchiveFiles@2
displayName: Archive circuit results
inputs:
rootFolderOrFile: 'test/visual/mpl/circuit/circuit_results'
archiveType: tar
archiveFile: '$(Build.ArtifactStagingDirectory)/circuit_results.tar.gz'
verbose: true
condition: failed()

- task: ArchiveFiles@2
displayName: Archive graph results
inputs:
rootFolderOrFile: 'test/visual/mpl/graph/graph_results'
archiveType: tar
archiveFile: '$(Build.ArtifactStagingDirectory)/graph_results.tar.gz'
verbose: true
condition: failed()

- task: PublishBuildArtifacts@1
displayName: 'Publish image test failure diffs'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'image_test_failure_img_diffs'
Parallel: true
ParallelCount: 8
condition: failed()
1 change: 1 addition & 0 deletions .github/workflows/neko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ jobs:
- uses: Qiskit/qiskit-neko@main
with:
test_selection: terra
repo_install_command: "pip install -c constraints.txt ."
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ qiskit-aer==0.12.0
# tests to flake. See https://github.com/Qiskit/qiskit-terra/issues/10305,
# remove pin when resolving that.
numpy<1.25

# Scipy 1.11 seems to have caused an instability in the Weyl coordinates
# eigensystem code for one of the test cases. See
# https://github.com/Qiskit/qiskit-terra/issues/10345 for current details.
scipy<1.11
2 changes: 1 addition & 1 deletion crates/accelerate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustworkx-core = "0.13"
# The base version of PyO3 and setting a minimum feature set (e.g. probably just 'extension-module')
# can be done in the workspace and inherited once we hit Rust 1.64.
[dependencies.pyo3]
version = "0.19.0"
version = "0.19.1"
features = ["extension-module", "hashbrown", "indexmap", "num-complex", "num-bigint", "abi3-py38"]

[dependencies.ndarray]
Expand Down
2 changes: 1 addition & 1 deletion crates/qasm2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ crate-type = ["cdylib"]

[dependencies]
hashbrown = "0.13.2"
pyo3 = { version = "0.19.0", features = ["extension-module", "abi3-py38"] }
pyo3 = { version = "0.19.1", features = ["extension-module", "abi3-py38"] }
14 changes: 11 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"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)
"numpy": ("https://numpy.org/doc/stable/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
}

# -- Options for HTML output -------------------------------------------------
Expand Down Expand Up @@ -112,17 +113,24 @@
"qiskit.pulse.library.Sin": "qiskit.pulse.library.Sin_class.rst",
"qiskit.pulse.library.Gaussian": "qiskit.pulse.library.Gaussian_class.rst",
"qiskit.pulse.library.Drag": "qiskit.pulse.library.Drag_class.rst",
"qiskit.pulse.library.Square": "qiskit.pulse.library.Square_fun.rst",
"qiskit.pulse.library.Sech": "qiskit.pulse.library.Sech_fun.rst",
}

autoclass_content = "both"


# -- Options for Doctest --------------------------------------------------------

doctest_default_flags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL | doctest.DONT_ACCEPT_TRUE_FOR_1
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 = ""
doctest_test_doctest_blocks = ""
2 changes: 1 addition & 1 deletion examples/python/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

# Desired vector
print("Desired probabilities: ")
print(list(map(lambda x: format(abs(x * x), ".3f"), desired_vector)))
print([format(abs(x * x), ".3f") for x in desired_vector])

# Initialize on local simulator
sim_backend = BasicAer.get_backend("qasm_simulator")
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repair-wheel-command = "cp {wheel} {dest_dir}/. && pipx run abi3audit --strict -

[tool.ruff]
select = [
"C4", # category: flake8-comprehensions
"F631",
"F632",
"F634",
Expand Down Expand Up @@ -82,14 +83,12 @@ disable = [
"consider-using-dict-items",
"consider-using-enumerate",
"consider-using-f-string",
"consider-using-from-import",
"modified-iterating-list",
"nested-min-max",
"no-member",
"no-value-for-parameter",
"non-ascii-name",
"not-context-manager",
"pointless-exception-statement",
"superfluous-parens",
"unknown-option-value",
"unexpected-keyword-arg",
Expand All @@ -105,7 +104,6 @@ disable = [
"use-list-literal",
"use-implicit-booleaness-not-comparison",
"use-maxsplit-arg",
"used-before-assignment",
]

enable = [
Expand Down
4 changes: 2 additions & 2 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
# to be placed *before* the wrapper imports or any non-import code AND *before*
# importing the package you want to allow extensions for (in this case `backends`).

# TODO: Remove when we drop support for importing qiskit-aer < 0.11.0 and the
# qiskit-ibmq-provider package is retired/archived.
# Support for the deprecated extending this namespace.
# Remove this after 0.46.0 release
__path__ = pkgutil.extend_path(__path__, __name__)

# Please note these are global instances, not modules.
Expand Down
100 changes: 60 additions & 40 deletions qiskit/algorithms/gradients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,74 +17,94 @@
.. currentmodule:: qiskit.algorithms.gradients
Estimator Gradients
===================
Base Classes
============
.. autosummary::
:toctree: ../stubs/
BaseEstimatorGradient
DerivativeType
FiniteDiffEstimatorGradient
LinCombEstimatorGradient
ParamShiftEstimatorGradient
SPSAEstimatorGradient
ReverseEstimatorGradient
BaseQGT
BaseSamplerGradient
EstimatorGradientResult
SamplerGradientResult
QGTResult
Sampler Gradients
=================
Finite Differences
==================
.. autosummary::
:toctree: ../stubs/
BaseSamplerGradient
FiniteDiffEstimatorGradient
FiniteDiffSamplerGradient
Linear Combination of Unitaries
===============================
.. autosummary::
:toctree: ../stubs/
LinCombEstimatorGradient
LinCombSamplerGradient
LinCombQGT
Parameter Shift Rules
=====================
.. autosummary::
:toctree: ../stubs/
ParamShiftEstimatorGradient
ParamShiftSamplerGradient
SPSASamplerGradient
Quantum Geometric Tensor
========================
Quantum Fisher Information
==========================
.. autosummary::
:toctree: ../stubs/
BaseQGT
LinCombQGT
QFIResult
QFI
Classical Methods
=================
.. autosummary::
:toctree: ../stubs/
ReverseEstimatorGradient
ReverseQGT
Results
=======
Simultaneous Perturbation Stochastic Approximation
==================================================
.. autosummary::
:toctree: ../stubs/
EstimatorGradientResult
QFIResult
QGTResult
SamplerGradientResult
SPSAEstimatorGradient
SPSASamplerGradient
"""

from .base_estimator_gradient import BaseEstimatorGradient
from .base_qgt import BaseQGT
from .base_sampler_gradient import BaseSamplerGradient
from .estimator_gradient_result import EstimatorGradientResult
from .finite_diff_estimator_gradient import FiniteDiffEstimatorGradient
from .finite_diff_sampler_gradient import FiniteDiffSamplerGradient
from .lin_comb_estimator_gradient import DerivativeType, LinCombEstimatorGradient
from .lin_comb_qgt import LinCombQGT
from .lin_comb_sampler_gradient import LinCombSamplerGradient
from .param_shift_estimator_gradient import ParamShiftEstimatorGradient
from .param_shift_sampler_gradient import ParamShiftSamplerGradient
from .base.base_estimator_gradient import BaseEstimatorGradient
from .base.base_qgt import BaseQGT
from .base.base_sampler_gradient import BaseSamplerGradient
from .base.estimator_gradient_result import EstimatorGradientResult
from .finite_diff.finite_diff_estimator_gradient import FiniteDiffEstimatorGradient
from .finite_diff.finite_diff_sampler_gradient import FiniteDiffSamplerGradient
from .lin_comb.lin_comb_estimator_gradient import DerivativeType, LinCombEstimatorGradient
from .lin_comb.lin_comb_qgt import LinCombQGT
from .lin_comb.lin_comb_sampler_gradient import LinCombSamplerGradient
from .param_shift.param_shift_estimator_gradient import ParamShiftEstimatorGradient
from .param_shift.param_shift_sampler_gradient import ParamShiftSamplerGradient
from .qfi import QFI
from .qfi_result import QFIResult
from .qgt_result import QGTResult
from .sampler_gradient_result import SamplerGradientResult
from .spsa_estimator_gradient import SPSAEstimatorGradient
from .spsa_sampler_gradient import SPSASamplerGradient
from .reverse_gradient.reverse_gradient import ReverseEstimatorGradient
from .reverse_gradient.reverse_qgt import ReverseQGT
from .base.qgt_result import QGTResult
from .base.sampler_gradient_result import SamplerGradientResult
from .spsa.spsa_estimator_gradient import SPSAEstimatorGradient
from .spsa.spsa_sampler_gradient import SPSASamplerGradient
from .reverse.reverse_gradient import ReverseEstimatorGradient
from .reverse.reverse_qgt import ReverseQGT

__all__ = [
"BaseEstimatorGradient",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
# (C) Copyright IBM 2022, 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
Expand All @@ -9,8 +9,3 @@
# 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.

"""Image comparison test for MPL circuit drawer.
You can generate the image references with Binder
in https://mybinder.org/v2/gh/<user>/<repo>/<branch>?urlpath=apps/test/ipynb/mpl_tester.ipynb
"""
Loading

0 comments on commit 433ac38

Please sign in to comment.