Skip to content

Add circuit traversal function for gate transformations#4

Merged
Krastanov merged 2 commits intomasterfrom
feature/circuit-traversal
Jan 18, 2026
Merged

Add circuit traversal function for gate transformations#4
Krastanov merged 2 commits intomasterfrom
feature/circuit-traversal

Conversation

@Krastanov
Copy link
Member

Summary

  • Introduces traversal(circuit, pair_transformation, direction, start, end) for applying transformations to adjacent pairs of circuit operations
  • Supports left-to-right (:right) and right-to-left (:left) traversal directions
  • The pair_transformation function can return: a 2-tuple (replace pair), single operation (combine), or nothing (no change)
  • Includes comprehensive test suite for traversal functionality

Test plan

  • Basic traversal tests (empty circuit, single element)
  • Swap transformation test (bubble sort behavior)
  • No-op transformation test
  • Combining transformation test (merge adjacent operations)
  • Left direction traversal test
  • Partial traversal with custom indices
  • Conditional transformation test
  • Invalid direction error handling

🤖 Generated with Claude Code

Introduces `traversal(circuit, pair_transformation, direction, start, end)`
for applying transformations to adjacent pairs of circuit operations.

Features:
- Left-to-right (:right) and right-to-left (:left) traversal directions
- Support for replacing pairs, combining operations, or no-op
- Configurable start and end indices for partial traversal

The pair_transformation function can return:
- A 2-tuple to replace the current pair
- A single operation to combine the pair
- `nothing` to leave unchanged

Also updates CLAUDE.md with traversal documentation and development workflow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jan 18, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Use Pauli() and isa_variant() directly instead of wrapping them
in make_pauli() and is_pauli() helpers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Krastanov Krastanov merged commit 959b640 into master Jan 18, 2026
12 of 16 checks passed
@Krastanov Krastanov deleted the feature/circuit-traversal branch January 18, 2026 13:27
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.

1 participant