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

Fix measure of pulse builder #2

Merged
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
14 changes: 9 additions & 5 deletions qiskit/pulse/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from .commands.sample_pulse import SamplePulse
from .reschedule import pad
from .schedule import Schedule
from qiskit.scheduler import measure as measure_schedule


backend_ctx = contextvars.ContextVar("backend")
schedule_ctx = contextvars.ContextVar("schedule")
Expand All @@ -22,7 +24,7 @@ def build(backend, schedule):
backend: a qiskit backend
schedule: a *mutable* pulse Schedule
"""
token1 = backend_ctx.set(backend.defaults())
token1 = backend_ctx.set(backend)
token2 = schedule_ctx.set(schedule)
token3 = instruction_list_ctx.set([])
try:
Expand Down Expand Up @@ -87,19 +89,21 @@ def qubit_channels(qubit: int):


def measure(qubit: int):
ism = backend_ctx.get().instruction_schedule_map
sched = measure_schedule(qubits=[qubit],
inst_map=backend_ctx.get().defaults().instruction_schedule_map,
meas_map=backend_ctx.get().configuration().meas_map)
instruction_list = instruction_list_ctx.get()
instruction_list.append(ism.get('measure', qubit))
instruction_list.append(sched)


def u1(qubit: int, p0):
ism = backend_ctx.get().instruction_schedule_map
ism = backend_ctx.get().defaults().instruction_schedule_map
instruction_list = instruction_list_ctx.get()
instruction_list.append(ism.get('u1', qubit, P0=p0))


def u2(qubit: int, p0, p1):
ism = backend_ctx.get().instruction_schedule_map
ism = backend_ctx.get().defaults().instruction_schedule_map
instruction_list = instruction_list_ctx.get()
instruction_list.append(ism.get('u2', qubit, P0=p0, P1=p1))

Expand Down