Skip to content

Commit

Permalink
fix: incorrectly formatted docstrings (#36)
Browse files Browse the repository at this point in the history
* fix: incorrectly formatted docstrings

* fix: shorten formula in docstring to be less than 88 chars
  • Loading branch information
dexter2206 authored Jan 2, 2023
1 parent 34917df commit 0424653
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/orquestra/vqa/ansatz/singlet_uccsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def screen_out_operator_terms_below_threshold(
) -> Tuple[np.ndarray, FermionOperator]:
"""Screen single and double excitation operators based on a guess
for the amplitudes
Args:
threshold (float): threshold to select excitations. Only those with
absolute amplitudes above the threshold are kept.
Expand All @@ -124,7 +125,7 @@ def screen_out_operator_terms_below_threshold(
Returns:
amplitudes (np.array): screened amplitudes
new_fermion_generator (openfermion.FermionOperator): screened
Fermion Operator
Fermion Operator
"""

new_fermion_generator = FermionOperator()
Expand Down
3 changes: 3 additions & 0 deletions src/orquestra/vqa/cost_function/cost_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def create_cost_function(
A callable CostFunction object.
Example use case:
.. code:: python
target_operator = ...
ansatz = ...
Expand Down
4 changes: 2 additions & 2 deletions src/orquestra/vqa/cost_function/qcbm_cost_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def create_QCBM_cost_function(
gradient_function: GradientFactory = finite_differences_gradient,
) -> CostFunction:
"""Cost function used for evaluating QCBM.
Args:
ansatz: the ansatz used to construct the variational circuits
runner: runner used for QCBM evaluation
Expand Down Expand Up @@ -74,8 +75,7 @@ def _create_QCBM_cost_function(
def cost_function(
parameters: np.ndarray, store_artifact: Optional[StoreArtifact] = None
) -> ValueEstimate:
"""
Evaluates the value of the cost function for given parameters.
"""Evaluates the value of the cost function for given parameters.
Args:
parameters: parameters for which the evaluation should occur.
Expand Down
16 changes: 8 additions & 8 deletions src/orquestra/vqa/shot_allocation/_shot_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ def estimate_nmeas_for_frames(
We are assuming the exact expectation values are provided
(i.e. infinite number of measurements or simulations without noise)
M ~ (sum_{i} prec(H_i)) ** 2.0 / (epsilon ** 2.0)
where prec(H_i) is the precision (square root of the variance)
:math:`M ~ (sum_{i} prec(H_i)) ** 2.0 / (epsilon ** 2.0)`
where :math:`prec(H_i)` is the precision (square root of the variance)
for each group of co-measurable terms H_{i}. It is computed as
prec(H_{i}) = sum{ab} |h_{a}^{i}||h_{b}^{i}| cov(O_{a}^{i}, O_{b}^{i})
where h_{a}^{i} is the coefficient of the a-th operator, O_{a}^{i}, in the
i-th group. Covariances are assumed to be zero for a != b:
cov(O_{a}^{i}, O_{b}^{i}) = <O_{a}^{i} O_{b}^{i}> - <O_{a}^{i}> <O_{b}^{i}> = 0
:math:`prec(H_{i}) = sum{ab} |h_{a}^{i}||h_{b}^{i}| cov(O_{a}^{i}, O_{b}^{i})`
where :math:`h_{a}^{i}` is the coefficient of the a-th operator, :math:`O_{a}^{i}`,
in the i-th group. Covariances are assumed to be zero for a != b:
:math:`cov(O_{a}^{i},O_{b}^{i})=<O_{a}^{i}O_{b}^{i}>-<O_{a}^{i}><O_{b}^{i}>=0`
Args:
frame_operators (List[PauliRepresentation]): A list of pauli operators, where
frame_operators: A list of pauli operators, where
each element in the list is a group of co-measurable terms.
expecval (Optional[ExpectationValues]): An ExpectationValues object containing
expecval: An ExpectationValues object containing
the expectation values of all operators in frame_operators. If absent,
variances are assumed to be maximal (i.e. equal to the square of the
term's coefficient). Note that the term coefficients should be
Expand Down

0 comments on commit 0424653

Please sign in to comment.