qiskit-documentation/docs/api/qiskit/0.40/qiskit.pulse.builder.build.mdx

52 lines
2.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: build
description: API reference for qiskit.pulse.builder.build
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.pulse.builder.build
---
# qiskit.pulse.builder.build
<Function id="qiskit.pulse.builder.build" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.23/qiskit/pulse/builder.py" signature="build(backend=None, schedule=None, name=None, default_alignment='left', default_transpiler_settings=None, default_circuit_scheduler_settings=None)">
Create a context manager for launching the imperative pulse builder DSL.
To enter a building context and starting building a pulse program:
```python
from qiskit import execute, pulse
from qiskit.providers.fake_provider import FakeOpenPulse2Q
backend = FakeOpenPulse2Q()
d0 = pulse.DriveChannel(0)
with pulse.build() as pulse_prog:
pulse.play(pulse.Constant(100, 0.5), d0)
```
While the output program `pulse_prog` cannot be executed as we are using a mock backend. If a real backend is being used, executing the program is done with:
```python
qiskit.execute(pulse_prog, backend)
```
**Parameters**
* **backend** ([*Backend*](qiskit.providers.Backend "qiskit.providers.Backend")) A Qiskit backend. If not supplied certain builder functionality will be unavailable.
* **schedule** (`Optional`\[[`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.schedule.ScheduleBlock")]) A pulse `ScheduleBlock` in which your pulse program will be built.
* **name** (`Optional`\[`str`]) Name of pulse program to be built.
* **default\_alignment** (`Union`\[`str`, [`AlignmentKind`](pulse#qiskit.pulse.transforms.AlignmentKind "qiskit.pulse.transforms.alignments.AlignmentKind"), `None`]) Default scheduling alignment for builder. One of `left`, `right`, `sequential` or an alignment context.
* **default\_transpiler\_settings** (`Optional`\[`Dict`\[`str`, `Any`]]) Default settings for the transpiler.
* **default\_circuit\_scheduler\_settings** (`Optional`\[`Dict`\[`str`, `Any`]]) Default settings for the circuit to pulse scheduler.
**Return type**
`AbstractContextManager`\[[`ScheduleBlock`](qiskit.pulse.ScheduleBlock "qiskit.pulse.schedule.ScheduleBlock")]
**Returns**
A new builder context which has the active builder initialized.
</Function>