Skip to content

Commit

Permalink
Avoid skipping channels in pulse visualizer (#8974)
Browse files Browse the repository at this point in the history
* Modify pulse visualizer test to fail due to missing channel

Reproduces #8981

* Avoid skipping channels in pulse visualizer

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
wshanks and mergify[bot] authored Oct 24, 2022
1 parent 90f45b4 commit 0ba7a43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions qiskit/visualization/pulse_v2/layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def channel_index_grouped_sort(

ordered_channels = []

for ind in inds:
for ind in sorted(inds):
# drive channel
if len(d_chans) > 0 and d_chans[-1].index == ind:
ordered_channels.append(d_chans.pop())
Expand Down Expand Up @@ -241,7 +241,7 @@ def channel_index_grouped_sort_u(

ordered_channels = []

for ind in inds:
for ind in sorted(inds):
# drive channel
if len(d_chans) > 0 and d_chans[-1].index == ind:
ordered_channels.append(d_chans.pop())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixed an issue where in some cases pulse visualization would omit some of
the channels in a schedule. Fixed #8981.
6 changes: 5 additions & 1 deletion test/python/visualization/pulse_v2/test_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def test_channel_type_grouped_sort(self):

def test_channel_index_sort(self):
"""Test channel_index_grouped_sort."""
# Add an unusual channel number to stress test the channel ordering
self.channels.append(pulse.DriveChannel(100))
self.channels.reverse()
out_layout = layouts.channel_index_grouped_sort(
self.channels, formatter=self.formatter, device=self.device
)
Expand All @@ -123,9 +126,10 @@ def test_channel_index_sort(self):
[pulse.MeasureChannel(2)],
[pulse.AcquireChannel(2)],
[pulse.ControlChannel(5)],
[pulse.DriveChannel(100)],
]

ref_names = ["D0", "U0", "D1", "M1", "A1", "D2", "U2", "M2", "A2", "U5"]
ref_names = ["D0", "U0", "D1", "M1", "A1", "D2", "U2", "M2", "A2", "U5", "D100"]

ref = list(zip(ref_names, ref_channels))

Expand Down

0 comments on commit 0ba7a43

Please sign in to comment.