Skip to content

Add Makie extension for circuit visualization#5

Merged
Krastanov merged 4 commits intomasterfrom
feature/makie-extension
Jan 18, 2026
Merged

Add Makie extension for circuit visualization#5
Krastanov merged 4 commits intomasterfrom
feature/makie-extension

Conversation

@Krastanov
Copy link
Member

Summary

  • Adds affectedqubits function using Moshi pattern matching to query qubit indices affected by operations
  • Creates PBCCompilerMakieExt package extension for circuit visualization when Makie is loaded
  • Implements circuitplot, circuitplot!, and circuitplot_axis functions
  • Gates rendered as colored rectangles spanning affected qubits with horizontal wire lines

Features

  • Gate visualization: Colored rectangles by operation type (Pauli=green, Measurement=red, etc.)
  • Qubit wires: Horizontal black lines for each qubit
  • Annotations: Measurement results show classical bit index, conditional ops show dependency
  • Configurable: Gate width, qubit spacing, colors all adjustable via Makie attributes
  • PrepMagic: Not visualized (placeholder for future implementation)

Test plan

  • Tests for affectedqubits on all CircuitOp variants
  • Tests for circuit-level affectedqubits
  • Existing tests still pass
  • Manual visual verification of plots (extension only loads with Makie)

🤖 Generated with Claude Code

This PR introduces:

1. `affectedqubits` function (src/affectedqubits.jl)
   - Returns sorted list of qubit indices affected by operations
   - Uses Moshi pattern matching (@match) for clean ADT handling
   - Works on both individual operations and entire circuits

2. Makie extension (ext/PBCCompilerMakieExt/)
   - Provides `circuitplot`, `circuitplot!`, `circuitplot_axis` functions
   - Gates drawn as colored rectangles spanning affected qubits
   - Horizontal qubit wire lines in background
   - Measurement results marked with classical bit index
   - Conditional operations marked with dependency index
   - Configurable gate colors, dimensions, and wire appearance

3. Plotting scaffolding (src/plotting.jl)
   - Function stubs for extension to implement

4. Tests for affectedqubits function

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

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 94.23077% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.60%. Comparing base (3ada356) to head (d5435e8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
ext/PBCCompilerMakieExt/PBCCompilerMakieExt.jl 93.25% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master       #5       +/-   ##
===========================================
+ Coverage   55.26%   78.60%   +23.34%     
===========================================
  Files           2        4        +2     
  Lines          76      187      +111     
===========================================
+ Hits           42      147      +105     
- Misses         34       40        +6     

☔ View full report in Codecov by Sentry.
📢 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.

Krastanov and others added 3 commits January 18, 2026 11:31
- Remove pattern matching mention from affectedqubits docstring
- Remove implementation detail from CLAUDE.md affected qubits section
- Add docstring guidelines to CLAUDE.md Development section

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add CairoMakie to test dependencies
- Create test_plotting.jl with tests for circuit visualization
- Fix @match import (use Moshi.Match, not Moshi.Data)
- Add *.png to .gitignore
- Add Julia invocation instructions (-tauto) to CLAUDE.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Krastanov Krastanov merged commit 2fc7840 into master Jan 18, 2026
16 of 20 checks passed
@Krastanov Krastanov deleted the feature/makie-extension branch January 18, 2026 17:48
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