Skip to content

Commit

Permalink
Change prefix of MemorySlot channel in Qasm Instructions (Qiskit#7078)
Browse files Browse the repository at this point in the history
  • Loading branch information
pollyshaw committed Jun 11, 2022
1 parent a18df14 commit 194132d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qiskit/pulse/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def __init__(self):
class MemorySlot(Channel):
"""Memory slot channels represent classical memory storage."""

prefix = "m"
prefix = "s"


class RegisterSlot(Channel):
Expand Down
2 changes: 2 additions & 0 deletions qiskit/qobj/converters/pulse_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ def get_channel(self, channel: str) -> channels.PulseChannel:
return channels.MeasureChannel(index)
elif prefix == channels.ControlChannel.prefix:
return channels.ControlChannel(index)
elif prefix == channels.MemorySlot.prefix:
return channels.MemorySlot(index)

raise QiskitError("Channel %s is not valid" % channel)

Expand Down
2 changes: 1 addition & 1 deletion test/python/pulse/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_default(self):
memory_slot = MemorySlot(123)

self.assertEqual(memory_slot.index, 123)
self.assertEqual(memory_slot.name, "m123")
self.assertEqual(memory_slot.name, "s123")


class TestRegisterSlot(QiskitTestCase):
Expand Down
13 changes: 12 additions & 1 deletion test/python/qobj/test_pulse_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_parameterized_shift_frequency(self):
self.assertEqual(evaluated_instruction.duration, 1)
self.assertEqual(evaluated_instruction.instructions[0][-1], instruction)

def test_delay(self):
def test_delay_drive_channel(self):
"""Test converted qobj from Delay."""
instruction = Delay(10, DriveChannel(0))

Expand All @@ -354,6 +354,17 @@ def test_delay(self):
self.assertEqual(converted_instruction.duration, instruction.duration)
self.assertEqual(converted_instruction.instructions[0][-1], instruction)

def test_delay_memory_slot(self):
"""Test converted qobj from Delay."""
instruction = Delay(10, MemorySlot(0))

qobj = PulseQobjInstruction(name="delay", ch="s0", t0=0, duration=10)
converted_instruction = self.converter(qobj)

self.assertTrue("delay" in qobj.to_dict().values())
self.assertEqual(converted_instruction.duration, instruction.duration)
self.assertEqual(converted_instruction.instructions[0][-1], instruction)

def test_acquire(self):
"""Test converted qobj from Acquire."""
schedule = Schedule()
Expand Down
2 changes: 1 addition & 1 deletion test/python/visualization/pulse_v2/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_gen_filled_waveform_stepwise_acquire(self):

# meta data check
ref_meta = {
"memory slot": "m0",
"memory slot": "s0",
"register slot": "N/A",
"discriminator": "test_discr",
"kernel": "N/A",
Expand Down

0 comments on commit 194132d

Please sign in to comment.