Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Qiskit/qiskit-addon-aqc-tensor into…
Browse files Browse the repository at this point in the history
… EA/docs-reorg
  • Loading branch information
Eric-Arellano committed Nov 11, 2024
2 parents 9f2a1e1 + 256b8b2 commit faf4e44
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 28 deletions.
4 changes: 1 addition & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

# pylint: disable=invalid-name

"""
Sphinx documentation builder
"""
"""Sphinx documentation builder."""

# General options:
import inspect
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ style = [
]
lint = [
"qiskit-addon-aqc-tensor[style]",
"pydocstyle==6.3.0",
"mypy==1.13.0",
"reno>=3.4.0",
"pylint==3.3.1",
# pydocstyle prefers to parse our pyproject.toml, hence the following line
"toml>=0.9.6",
]
docs = [
"Sphinx>=3.0.0",
Expand Down Expand Up @@ -135,16 +132,20 @@ ignore = [
extend-select = [
"I", # sort imports
"CPY", # copyright notices
"D", # pydocstyle
]

[tool.ruff.lint.per-file-ignores]
"test/**.py" = [
"F405", # star import
"F403", # unable to detect undefined names due to star import
"D", # pydocstyle
]
"docs/**" = [
"E402", # module level import not at top of file
"CPY", # copyright notices
"D100", # missing docstring in public module
"D103", # missing docstring in public function
]

[tool.ruff.lint.flake8-copyright]
Expand All @@ -162,6 +163,10 @@ notice-rgx = """
# that they have been altered from the originals\\.
"""

[tool.ruff.lint.pydocstyle]
convention = "google"
ignore-decorators = ["plum.dispatch"]

[tool.pylint.main]
py-version = "3.9"
disable = "all"
Expand Down
4 changes: 1 addition & 3 deletions qiskit_addon_aqc_tensor/ansatz_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# that they have been altered from the originals.

# Reminder: update the RST file in docs/apidocs when adding new interfaces.
"""
Utility for generating a general, parametrized, ansatz circuit which matches the two-qubit connectivity of an input circuit.
"""
"""Utility for generating a general, parametrized, ansatz circuit which matches the two-qubit connectivity of an input circuit."""

from __future__ import annotations

Expand Down
6 changes: 2 additions & 4 deletions qiskit_addon_aqc_tensor/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
Code for building and evaluating objective functions used for AQC parameter optimization.
"""Code for building and evaluating objective functions used for AQC parameter optimization.
Currently, this module provides the simplest possible objective function, :class:`.OneMinusFidelity`.
"""
Expand Down Expand Up @@ -53,8 +52,7 @@ def __init__(
ansatz: QuantumCircuit,
settings: TensorNetworkSimulationSettings,
):
"""
Initialize the objective function.
"""Initialize the objective function.
Args:
ansatz: Parametrized ansatz circuit.
Expand Down
3 changes: 1 addition & 2 deletions qiskit_addon_aqc_tensor/simulation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
This module provides an interface to tensor-network simulation that is agnostic to which backend is used.
"""This module provides an interface to tensor-network simulation that is agnostic to which backend is used.
Currently, there is a single implementation, which uses the Qiskit Aer matrix-product state (MPS) simulator as its backend.
"""
Expand Down
3 changes: 1 addition & 2 deletions qiskit_addon_aqc_tensor/simulation/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def _compute_objective_and_gradient(
def _compute_overlap_with_local_gate_applied(
psi_1: TensorNetworkState, gate: Gate, qubit: int, psi_2: TensorNetworkState, /
) -> complex: # pragma: no cover
r"""
Compute overlap of two quantum states with a single local (one-qubit) gate in the middle.
r"""Compute overlap of two quantum states with a single local (one-qubit) gate in the middle.
:math:`\langle \psi_1 | G | \psi_2 \rangle`.
Expand Down
3 changes: 1 addition & 2 deletions qiskit_addon_aqc_tensor/simulation/aer/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def _aer_mps_from_circuit(
*,
out_state: np.ndarray | None = None,
) -> QiskitAerMPS:
r"""
Compute the result of action ``output = circuit @ |0>`` in MPS format.
r"""Compute the result of action ``output = circuit @ |0>`` in MPS format.
Args:
qc: quantum circuit acting on state :math:`|0\rangle`.
Expand Down
10 changes: 4 additions & 6 deletions qiskit_addon_aqc_tensor/simulation/explicit_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
# 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.
r"""
Functions for computing the gradient of :math:`\langle 0 | V^{\dagger}(\vec\theta) | \psi \rangle`.
r"""Functions for computing the gradient of :math:`\langle 0 | V^{\dagger}(\vec\theta) | \psi \rangle`.
The purpose of this module is to enable the objective function evaluation (:mod:`qiskit_addon_aqc_tensor.objective`)
to have access to the gradient alongside the function's value.
Expand Down Expand Up @@ -53,8 +52,7 @@


def _compute_gate_to_parameter_mapping(qc: QuantumCircuit, /) -> dict[str, int]:
"""
Compute mapping between the parameter name and the index of the corresponding entry in the :class:`.ParameterVector` object.
"""Compute mapping between the parameter name and the index of the corresponding entry in the :class:`.ParameterVector` object.
Recall, Qiskit assigns the parameters sorted by parameter name.
This remains unique under circuit transformation, and therefore binding
Expand Down Expand Up @@ -299,8 +297,7 @@ def compute_gradient_of_tensornetwork_overlap(
lhs: TensorNetworkState,
vdagger_rhs: TensorNetworkState,
) -> np.ndarray:
r"""
Compute gradient of the dot product :math:`\langle \mathrm{lhs} | V^\dagger(\vec\theta) | \mathrm{rhs} \rangle` using tensor networks.
r"""Compute gradient of the dot product :math:`\langle \mathrm{lhs} | V^\dagger(\vec\theta) | \mathrm{rhs} \rangle` using tensor networks.
Here, :math:`V` is a parametric circuit (ansatz), :math:`| \mathrm{rhs} \rangle` is a target state
(right-hand side vector as a :class:`.TensorNetworkState`), and :math:`| \mathrm{lhs} \rangle` is a low-entangled
Expand All @@ -315,6 +312,7 @@ def compute_gradient_of_tensornetwork_overlap(
thetas: angular parameters of the circuit.
lhs: left-hand side vector as a :class:`.TensorNetworkState`.
vdagger_rhs: :math:`V^\dagger(\vec\theta)` times the right-hand side vector as a :class:`.TensorNetworkState`.
Returns:
Vector of complex gradients.
"""
Expand Down
4 changes: 2 additions & 2 deletions qiskit_addon_aqc_tensor/simulation/quimb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def is_quimb_available() -> bool:
class QuimbCircuitFactory(Protocol):
"""Quimb circuit factory."""

def __call__(
def __call__( # noqa: D102
self, *, N: int, psi0: quimb.tensor.TensorNetworkGenVector | None = None
) -> quimb.tensor.Circuit: # noqa: D102; # pragma: no cover
) -> quimb.tensor.Circuit: # pragma: no cover
...


Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ commands =
nbqa ruff docs/
autoflake --check --quiet --recursive qiskit_addon_aqc_tensor docs/ test/
black --check qiskit_addon_aqc_tensor docs/ test/
pydocstyle qiskit_addon_aqc_tensor --ignore-decorators=dispatch
mypy qiskit_addon_aqc_tensor --disable-error-code no-redef
reno lint
pylint -rn qiskit_addon_aqc_tensor test/
Expand Down

0 comments on commit faf4e44

Please sign in to comment.