Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrections to docs for intersphinx #311

Merged
merged 13 commits into from
Jul 11, 2023
18 changes: 9 additions & 9 deletions circuit_knitting/cutting/cutting_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ def partition_circuit_qubits(
circuit: QuantumCircuit, partition_labels: Sequence[Hashable], inplace: bool = False
) -> QuantumCircuit:
r"""
Replace all nonlocal gates belonging to more than one partition with instances of :class:`TwoQubitQPDGate`.
Replace all nonlocal gates belonging to more than one partition with instances of :class:`.TwoQubitQPDGate`.

:class:`TwoQubitQPDGate`\ s belonging to a single partition will not be affected.
:class:`.TwoQubitQPDGate`\ s belonging to a single partition will not be affected.

Args:
circuit: The circuit to partition
partition_labels: A sequence containing a partition label for each qubit in the
input circuit. Nonlocal gates belonging to more than one partition
will be replaced with :class:`TwoQubitQPDGate`\ s.
will be replaced with :class:`.TwoQubitQPDGate`\ s.
inplace: Flag denoting whether to copy the input circuit before acting on it

Returns:
The output circuit with each nonlocal gate spanning two partitions replaced by a
:class:`TwoQubitQPDGate`
:class:`.TwoQubitQPDGate`

Raises:
ValueError: The length of partition_labels does not equal the number of qubits in the circuit.
Expand Down Expand Up @@ -119,7 +119,7 @@ def decompose_gates(
circuit: QuantumCircuit, gate_ids: Sequence[int], inplace: bool = False
) -> tuple[QuantumCircuit, list[QPDBasis]]: # pragma: no cover
r"""
Transform specified gates into :class:`TwoQubitQPDGate`\ s.
Transform specified gates into :class:`.TwoQubitQPDGate`\ s.

Deprecated as of 0.3.0. Instead, use :func:`~circuit_knitting.cutting.cut_gates`.
"""
Expand All @@ -130,16 +130,16 @@ def cut_gates(
circuit: QuantumCircuit, gate_ids: Sequence[int], inplace: bool = False
) -> tuple[QuantumCircuit, list[QPDBasis]]:
r"""
Transform specified gates into :class:`TwoQubitQPDGate`\ s.
Transform specified gates into :class:`.TwoQubitQPDGate`\ s.

Args:
circuit: The circuit containing gates to be decomposed
gate_ids: The indices of the gates to decompose
inplace: Flag denoting whether to copy the input circuit before acting on it

Returns:
A copy of the input circuit with the specified gates replaced with :class:`TwoQubitGate`\ s
and a list of :class:`QPDBasis` instances -- one for each decomposed gate.
A copy of the input circuit with the specified gates replaced with :class:`.TwoQubitQPDGate`\ s
and a list of :class:`.QPDBasis` instances -- one for each decomposed gate.

Raises:
ValueError: The input circuit should contain no classical bits or registers.
Expand Down Expand Up @@ -173,7 +173,7 @@ def partition_problem(
Separate an input circuit and observable(s) along qubit partition labels.

Circuit qubits with matching partition labels will be grouped together, and non-local
gates spanning more than one partition will be replaced with :class:`TwoQubitQPDGate`\ s.
gates spanning more than one partition will be replaced with :class:`.TwoQubitQPDGate`\ s.

If provided, the observables will be separated along the boundaries specified by
``partition_labels``.
Expand Down
4 changes: 2 additions & 2 deletions circuit_knitting/cutting/cutting_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def execute_experiments(
Args:
circuits: The circuit(s) resulting from decomposing nonlocal gates
subobservables: The subobservable(s) corresponding to the circuit(s). If
a :external:class:`~qiskit.circuit.QuantumCircuit` is submitted for the ``circuits`` argument,
a :external:class:`~qiskit.quantum_info.PauliList` is expected; otherwise, a mapping
a :class:`~qiskit.circuit.QuantumCircuit` is submitted for the ``circuits`` argument,
a :class:`~qiskit.quantum_info.PauliList` is expected; otherwise, a mapping
from partition label to subobservables is expected.
num_samples: The number of samples to draw from the quasiprobability distribution
samplers: Sampler(s) on which to run the sub-experiments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def get_eigenvalue_evaluation(
Args:
operator: The decomposed Hamiltonian in entanglement forging format
Returns:
Callable function which provides an estimation of the mihnimum eigenvalue
Callable function which provides an estimation of the minimum eigenvalue
of the input operator given some ansatz circuit parameters.
"""

Expand Down
2 changes: 1 addition & 1 deletion circuit_knitting/forging/entanglement_forging_knitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _partition(a, n):
n: The number of partitions

Returns:
The generator containing the paritions
The generator containing the partitions
"""
k, m = divmod(len(a), n)
return (a[i * k + min(i, m) : (i + 1) * k + min(i + 1, m)] for i in range(n))
Expand Down
9 changes: 5 additions & 4 deletions circuit_knitting/forging/entanglement_forging_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
class EntanglementForgingOperator: # noqa: D301
r"""Operator class for Entanglement Forging.

A class that contains the :math:`2N` qubit Pauli operator :math:`\hat{O} = \sum_{i, j} w_{i, j} \hat{T}_{i, j} \otimes \sum_{a, b} \hat{S}_{a, b}`
and associated weights. These operators are knitted by the :class:`EntanglementForgingKnitter` to provide esimates of the
energy for the :class:`EntanglementForgingVQE`.
A class that contains the :math:`2N` qubit Pauli operator :math:`\hat{O} = \sum_{i, j} w_{i, j} \hat{T}_{i,
j} \otimes \sum_{a, b} \hat{S}_{a, b}` and associated weights. These operators are knitted by the
:class:`.EntanglementForgingKnitter` to provide estimates of the energy for the
:class:`.EntanglementForgingGroundStateSolver`.
"""

def __init__(
Expand Down Expand Up @@ -55,7 +56,7 @@ def __repr__(self) -> str:
Representation function for EntanglementForgingOperator.

Returns:
Printable repesentation of class
Printable representation of class
"""
repr = "EntanglementForgingOperator\nTensor Paulis:\n"
repr += str(self.tensor_paulis)
Expand Down
38 changes: 18 additions & 20 deletions circuit_knitting/utils/observable_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def observables_restricted_to_subsystem(
) -> list[Pauli] | PauliList:
"""Restrict each observable to its support on a given subsystem.

A ``PauliList`` will be returned if a ``PauliList`` is provided; otherwise,
A :class:`~qiskit.quantum_info.PauliList` will be returned if a :class:`~qiskit.quantum_info.PauliList` is provided; otherwise,
a ``list[Pauli]`` will be returned.

Args:
qubits: The qubits in a subsystem
global_observables: The list of observables

Returns:
Each Pauli restricted to the subsystem.
Each :class:`~qiskit.quantum_info.Pauli` restricted to the subsystem.

>>> observables_restricted_to_subsystem([1, 3], PauliList(["IXYZ", "ZZXX"]))
PauliList(['IY', 'ZX'])
Expand Down Expand Up @@ -125,22 +125,20 @@ def most_general_observable(

@dataclass(frozen=True)
class CommutingObservableGroup:
r"""Set of mutually qubit-wise commuting observables.

Attributes:
commuting_observables: Those that can be measured simultaneously
general_observable: A single Pauli string that contains all
qubit-wise measurements needed to measure everything in ``commuting_observables``.
pauli_indices: The indices of non-identity ``Pauli``\ s in ``general_observable``
pauli_bitmasks: A bitmask for each observable in
``commuting_observables``. Given an element, each bit corresponds to
whether the corresponding entry in ``pauli_indices`` is relevant to
that observable.
"""
r"""Set of mutually qubit-wise commuting observables."""

#: A single Pauli string that contains all qubit-wise measurements needed
#: to measure everything in ``commuting_observables``.
general_observable: Pauli

#: Observables that can be measured simultaneously.
commuting_observables: list[Pauli]

#: The indices of non-identity :class:`~qiskit.quantum_info.Pauli`\ s in ``general_observable``.
pauli_indices: list[int] = field(init=False)

#: A bitmask for each observable in ``commuting_observables``; given an element, each bit corresponds to whether
#: the corresponding entry in ``pauli_indices`` is relevant to that observable.
pauli_bitmasks: list[int] = field(init=False)

def __post_init__(self) -> None:
Expand Down Expand Up @@ -174,7 +172,7 @@ class ObservableCollection:

The observables are automatically organized into sets of mutually
qubit-wise commuting observables, each represented by a
``CommutingObservableGroup``.
:class:`.CommutingObservableGroup`.
"""

def __init__(self, observables: PauliList | Iterable[Pauli], /):
Expand Down Expand Up @@ -255,19 +253,19 @@ def construct_general_observables(

@property
def groups(self) -> list[CommutingObservableGroup]:
r"""List of ``CommutingObservableGroup``\ s which, together, contain all desired observables."""
r"""List of :class:`.CommutingObservableGroup`\ s which, together, contain all desired observables."""
return self._groups

@property
def lookup(self) -> dict[Pauli, list[tuple[int, int]]]:
r"""Get dict which maps each ``Pauli`` observable to a list of ``(i, j)`` pairs.
r"""Get dict which maps each :class:`~qiskit.quantum_info.Pauli` observable to a list of ``(i, j)`` pairs.

For each element of the list, it means that the ``Pauli`` is given by
For each element of the list, it means that the :class:`~qiskit.quantum_info.Pauli` is given by
the ``j``th commuting observable in the ``i``th group.

This list will be of length 1 at minimum, but may potentially be longer
if multiple ``CommutingObservableGroup``\ s are compatible with the given
``Pauli``.
if multiple :class:`.CommutingObservableGroup`\ s are compatible with the given
:class:`~qiskit.quantum_info.Pauli`.

"""
return self._lookup
4 changes: 2 additions & 2 deletions circuit_knitting/utils/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ class ExactSampler(BaseSampler):
- some (or all) classical bits can remain unused
- classical bits can be written more than once

The samplers provided by ``qiskit.primitives`` and
``qiskit_aer.primitives`` do not currently support all of the above
The samplers provided by :mod:`qiskit.primitives` and
:mod:`qiskit_aer.primitives` do not currently support all of the above
functionality. Related upstream issues:

- https://github.com/Qiskit/qiskit-terra/issues/9657
Expand Down
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,8 @@
"numpy": ("https://numpy.org/doc/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
"qiskit": ("https://qiskit.org/documentation/", None),
"qiskit-ibm-runtime": ("https://qiskit.org/ecosystem/ibm-runtime/", None),
"qiskit-aer": ("https://qiskit.org/ecosystem/aer/", None),
"qiskit-nature": ("https://qiskit.org/ecosystem/nature/", None),
"rustworkx": ("https://qiskit.org/documentation/rustworkx/", None),
}
4 changes: 2 additions & 2 deletions test/forging/test_entanglement_forging_ground_state_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Tests for EntanglementForgingVQE module."""
"""Tests for EntanglementForgingGroundStateSolver module."""

import unittest
import importlib.util
Expand Down Expand Up @@ -39,7 +39,7 @@ def setUp(self):

@unittest.skipIf(not pyscf_available, "pyscf is not installed")
def test_entanglement_forging_vqe_hydrogen(self):
"""Test of applying Entanglement Forged Solver to to compute the energy of a H2 molecule."""
"""Test of applying Entanglement Forged Solver to compute the energy of a H2 molecule."""
# Set up the ElectronicStructureProblem
driver = PySCFDriver(
atom="H .0 .0 .0; H .0 .0 0.735",
Expand Down