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

Avoid skipping channels in pulse visualizer #8974

Merged
merged 3 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
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
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