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

Minor fixes for markdown code examples #666

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/build/interoperate-qiskit-qasm2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Qiskit provides some tools for converting between OpenQASM representations of qu
Currently two high-level functions are available for importing from OpenQASM 2 into Qiskit. These functions are `qasm2.load()`, which takes a file name, and `qasm2.loads()`, which takes the program itself as a string.

```python
import qiskit.qasm2
qiskit.qasm2.load(filename, *, include_path=('.',), include_input_directory='append', custom_instructions=(), custom_classical=(), strict=False)
```

Expand Down Expand Up @@ -110,7 +111,7 @@ Use `qasm2.loads()` to import an OpenQASM 2 program as a string into a QuantumCi

```python
import math
from qiskit.qasm2
import qiskit.qasm2

program = '''
include "qelib1.inc";
Expand Down
13 changes: 8 additions & 5 deletions docs/build/interoperate-qiskit-qasm3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ This function is still in the exploratory phase. Therefore, it is likely that t

## Import an OpenQASM 3 program into Qiskit

You must install the package `qiskit_qasm3_import ` to use this function. Install using the following command.

```python
pip install qiskit-qasm3-import
```

Currently two high-level functions are available for importing from OpenQASM 3 into Qiskit. These functions are `load()`, which takes a file name, and `loads()`, which takes the program itself as a string:


```python
import qiskit.qasm3
qiskit.qasm3.load(file_name)
```

```python
import qiskit.qasm3
qiskit.qasm3.loads(program-string)
```

You must install the package `qiskit_qasm3_import ` to use this function. For example:

```python
pip install qiskit-qasm3-import
```

In this example, we define a quantum program using OpenQASM 3, and use `loads()` to directly convert it into a QuantumCircuit:

Expand Down
18 changes: 11 additions & 7 deletions docs/transpile/common-parameters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ When the approximation degree is less than 1.0, circuits with one or two CX gate
As an example, we generate a random 2-qubit `UnitaryGate` which will be synthesized in the initial stage. Setting the `approximation_degree` less than 1.0 might generate an approximate circuit. We must also specify the `basis_gates` to let the synthesis method know which gates it can use for the approximate synthesis.

```python
UU = random_unitary(4, seed=12345)
rand_U = UnitaryGate(UU)
from qiskit import QuantumCircuit, transpile
from qiskit.circuit.library import UnitaryGate
from qiskit.quantum_info import random_unitary

qc = QuantumCircuit(2)
qc.append(rand_U, range(2))
approx_qc = transpile(qc, approximation_degree=0.85, basis_gates=["sx", "rz", "cx"])
print(approx_qc.count_ops()["cx"])
UU = random_unitary(4, seed=12345)
rand_U = UnitaryGate(UU)

qc = QuantumCircuit(2)
qc.append(rand_U, range(2))
approx_qc = transpile(qc, approximation_degree=0.85, basis_gates=["sx", "rz", "cx"])
print(approx_qc.count_ops()["cx"])
```

This yields an output of `2` because the approximation requires fewer CX gates.
Expand All @@ -38,7 +42,7 @@ The seed transpiler argument sets the random seed for the stochastic parts of th
Example:

```python
optimized_1 = transpile(qc, backend=backend, seed_transpiler=11, optimization_level=1)
optimized_1 = transpile(qc, seed_transpiler=11, optimization_level=1)
```

<span id="init-layout"></span>
Expand Down