Skip to content

QCDL signals: accept any group of qubits as one_to_all destinations - #74

Open
qci-amos wants to merge 3 commits into
mainfrom
qcdl/one-to-all-destination-forms
Open

QCDL signals: accept any group of qubits as one_to_all destinations#74
qci-amos wants to merge 3 commits into
mainfrom
qcdl/one-to-all-destination-forms

Conversation

@qci-amos

Copy link
Copy Markdown
Collaborator

Part of splitting #71 into reviewable pieces. Independent of the other four.

The problem

QCDLModule.one_to_all was annotated and written for a Scope only, reaching
straight for destinations.qcdl_modules and destinations.scope_id. Passing
anything else — including scope.qcdl_modules, which is what the user guide
shows in places — raised AttributeError: 'list' object has no attribute 'scope_id'. Sending to a single qubit meant wrapping it in a Scope first.

The change

_as_modules normalizes the destinations into a list of modules, accepting a
Scope, a single QCDLModule, or a sequence of either, and deduplicating by
name while preserving order.

scope_id is only carried through when a Scope was actually passed: a bare
sequence has no identity of its own, so tagging its statements with someone
else's scope id would be a lie. That distinction is covered by a test.

A non-module destination, or an empty one, now raises QCDLUserError naming
the parameter, rather than surfacing as an AttributeError on an internal
attribute further down.

Compatibility

Purely widening — every call that worked before works unchanged and produces
the same statement.

Testing

pytest tests/ passes. tests/test_scope.py parameterizes over each accepted
destination form (scope, list, tuple, reversed list, single module, mixed,
repeated) and asserts the resulting qubit list, plus the scope_id rule and
the three rejection cases.

🤖 Generated with Claude Code

one_to_all only accepted a Scope, so passing scope.qcdl_modules -- which
is what the user guide shows -- raised an AttributeError on scope_id, and
sending to a single qubit meant wrapping it in a Scope first.

_as_modules normalizes a Scope, a QCDLModule, or a sequence of either
into modules, deduplicating by name while preserving order, and reports a
non-module argument as a QCDLUserError instead of letting it fail later.
Statements keep a scope_id only when a Scope was passed, since a bare
sequence has no identity of its own.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.21429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.26%. Comparing base (206a2d6) to head (f14aebf).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
dwave/gate/qcdl/components.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
+ Coverage   90.18%   90.26%   +0.08%     
==========================================
  Files          31       31              
  Lines        5317     5373      +56     
==========================================
+ Hits         4795     4850      +55     
- Misses        522      523       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread dwave/gate/qcdl/components.py Outdated
Comment thread dwave/gate/qcdl/components.py Outdated
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Comment thread dwave/gate/qcdl/components.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants