mirror of https://github.com/Qiskit/qiskit.git
Fix UnassignedDurationError of update_from_instruction_schedule_map (#10447)
* fix UnassignedDurationError of update_from_instruction_schedule_map * add test * add reno * rename test * fix reno * Update releasenotes/notes/fix-update-from-instruction-schedule-map-d1cba4e4db4b679e.yaml --------- Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
This commit is contained in:
parent
d13f0bbad6
commit
ac29776243
|
@ -43,7 +43,7 @@ from qiskit.transpiler.exceptions import TranspilerError
|
|||
from qiskit.transpiler.instruction_durations import InstructionDurations
|
||||
from qiskit.transpiler.timing_constraints import TimingConstraints
|
||||
from qiskit.providers.exceptions import BackendPropertyError
|
||||
from qiskit.pulse.exceptions import PulseError
|
||||
from qiskit.pulse.exceptions import PulseError, UnassignedDurationError
|
||||
from qiskit.utils.deprecation import deprecate_arg, deprecate_func
|
||||
from qiskit.exceptions import QiskitError
|
||||
|
||||
|
@ -505,7 +505,11 @@ class Target(Mapping):
|
|||
# It only copies user-provided calibration from the inst map.
|
||||
# Backend defined entry must already exist in Target.
|
||||
if self.dt is not None:
|
||||
duration = entry.get_schedule().duration * self.dt
|
||||
try:
|
||||
duration = entry.get_schedule().duration * self.dt
|
||||
except UnassignedDurationError:
|
||||
# duration of schedule is parameterized
|
||||
duration = None
|
||||
else:
|
||||
duration = None
|
||||
props = InstructionProperties(
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed an failure of :meth:`.Target.update_from_instruction_schedule_map` when
|
||||
the argument ``inst_map`` has schedule with unassigned duration.
|
||||
|
|
@ -1210,6 +1210,20 @@ Instructions:
|
|||
target.update_from_instruction_schedule_map(inst_map, {"sx": SXGate()})
|
||||
self.assertEqual(inst_map, target.instruction_schedule_map())
|
||||
|
||||
def test_update_from_instruction_schedule_map_with_schedule_parameter(self):
|
||||
self.pulse_target.dt = None
|
||||
inst_map = InstructionScheduleMap()
|
||||
duration = Parameter("duration")
|
||||
|
||||
with pulse.build(name="sx_q0") as custom_sx:
|
||||
pulse.play(pulse.Constant(duration, 0.2), pulse.DriveChannel(0))
|
||||
|
||||
inst_map.add("sx", 0, custom_sx, ["duration"])
|
||||
|
||||
target = Target(dt=3e-7)
|
||||
target.update_from_instruction_schedule_map(inst_map, {"sx": SXGate()})
|
||||
self.assertEqual(inst_map, target.instruction_schedule_map())
|
||||
|
||||
def test_update_from_instruction_schedule_map_update_schedule(self):
|
||||
self.pulse_target.dt = None
|
||||
inst_map = InstructionScheduleMap()
|
||||
|
|
Loading…
Reference in New Issue