QCDL signals: accept any group of qubits as one_to_all destinations - #74
Open
qci-amos wants to merge 3 commits into
Open
QCDL signals: accept any group of qubits as one_to_all destinations#74qci-amos wants to merge 3 commits into
qci-amos wants to merge 3 commits into
Conversation
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
JoelPasvolsky
approved these changes
Aug 19, 2026
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
qci-amos
commented
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of splitting #71 into reviewable pieces. Independent of the other four.
The problem
QCDLModule.one_to_allwas annotated and written for aScopeonly, reachingstraight for
destinations.qcdl_modulesanddestinations.scope_id. Passinganything else — including
scope.qcdl_modules, which is what the user guideshows in places — raised
AttributeError: 'list' object has no attribute 'scope_id'. Sending to a single qubit meant wrapping it in aScopefirst.The change
_as_modulesnormalizes the destinations into a list of modules, accepting aScope, a singleQCDLModule, or a sequence of either, and deduplicating byname while preserving order.
scope_idis only carried through when aScopewas actually passed: a baresequence 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
QCDLUserErrornamingthe parameter, rather than surfacing as an
AttributeErroron an internalattribute further down.
Compatibility
Purely widening — every call that worked before works unchanged and produces
the same statement.
Testing
pytest tests/passes.tests/test_scope.pyparameterizes over each accepteddestination form (scope, list, tuple, reversed list, single module, mixed,
repeated) and asserts the resulting qubit list, plus the
scope_idrule andthe three rejection cases.
🤖 Generated with Claude Code