Skip to content

Commit

Permalink
Update executor and observable docs (#2594)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdg221 authored Dec 9, 2024
1 parent da77ec0 commit 7648648
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion docs/source/guide/executors.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ To instantiate an `Executor`, provide a function which either:
1. Inputs a `mitiq.QPROGRAM` and outputs a `mitiq.QuantumResult`.
2. Inputs a sequence of `mitiq.QPROGRAM`s and outputs a sequence of `mitiq.QuantumResult`s.

**The function must be [annotated](https://peps.python.org/pep-3107/) to tell Mitiq which type of `QuantumResult` it returns. Functions with no annotations are assumed to return `float`s.**
```{warning}
To avoid confusion and invalid results, the executor function must be [annotated](https://peps.python.org/pep-3107/) to tell Mitiq which type of `QuantumResult` it returns. Functions without annotations are assumed to return `float`s.
```

A `QPROGRAM` is "something which a quantum computer inputs" and a `QuantumResult` is "something which a quantum computer outputs." The latter is canonically a bitstring for real quantum hardware, but can be other objects for testing, e.g. a density matrix.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/guide/observables.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ obs.expectation(circuit, execute=mitiq_cirq.sample_bitstrings)

In error mitigation techniques, you can provide an observable to specify the expectation value to mitigate.

```{admonition} Note:
When specifying an `Observable`, you must ensure that the return type of the executor function is `MeasurementResultLike` or `DensityMatrixLike`.
```{warning}
As note in the [executor documentation](./executors.md#the-input-function), the executor must be annotated with the appropriate type hinting for the return type. Additionally, when specifying an `Observable`, you must ensure that the return type of the executor function is `MeasurementResultLike` or `DensityMatrixLike`.
```

```{code-cell} ipython3
Expand Down

0 comments on commit 7648648

Please sign in to comment.