Skip to content

Add Wigner function computation and Makie visualization extension#227

Open
Aniket-umass wants to merge 14 commits into
qojulia:masterfrom
Aniket-umass:makie-wigner-extension
Open

Add Wigner function computation and Makie visualization extension#227
Aniket-umass wants to merge 14 commits into
qojulia:masterfrom
Aniket-umass:makie-wigner-extension

Conversation

@Aniket-umass

@Aniket-umass Aniket-umass commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Plot examples:
Coherent state:
test_coherent

Fock state:
test_fock png 23-21-43-861

Adds a Makie recipe for visualizing the Wigner quasi-probability distribution of quantum states as a 2D heatmap, following the same extension pattern as the existing Bloch sphere visualization.
Changes

ext/QuantumOpticsBaseMakieExt.jl: Adds WignerPlot recipe producing a heatmap with a diverging colormap (:RdBu) pinned to zero, so positive regions (blue) and negative regions (red) are visually distinct. Supports reactive
Observable state updates.

src/visualization.jl: Adds function stubs for wignerplot, wignerplot!, and wignerplot_axis.

src/QuantumOpticsBase.jl: Exports the three new visualization functions.

test/test_wigner_plotting.jl: Tests for return types, coherent/Fock state rendering, custom attributes (xrange, prange, npoints, colormap), Observable reactivity, and error handling for unsupported basis types.

test/Project.toml: Adds Makie as a test dependency (needed for using Makie: Observable in both Bloch sphere and Wigner tests).

@Aniket-umass Aniket-umass force-pushed the makie-wigner-extension branch from c41d915 to b2b44c3 Compare June 3, 2026 11:59
@Krastanov

Copy link
Copy Markdown
Member

FYI, currently this PR seems to be deleting what was added in the previous PR. Something was probably messed up when resolving the merge conflict

@Aniket-umass

Copy link
Copy Markdown
Contributor Author

FYI, currently this PR seems to be deleting what was added in the previous PR. Something was probably messed up when resolving the merge conflict

Alright, I will look into it

@Aniket-umass Aniket-umass force-pushed the makie-wigner-extension branch 2 times, most recently from 063704a to f34fa71 Compare June 3, 2026 23:12
@Aniket-umass Aniket-umass force-pushed the makie-wigner-extension branch from f34fa71 to 338ae1c Compare June 4, 2026 03:16
@Aniket-umass

Copy link
Copy Markdown
Contributor Author

All Wigner and Bloch sphere plotting tests pass (9/9 each). The remaining CI failures (sciml_broadcast_interfaces, aqua, apply, Documentation, Downgrade) are pre-existing on the master branch.

@Krastanov Krastanov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, up to minor test clarification. Still outstanding need to make error hints that point out the need for Makie backends so that the method errors are more legible.

Comment thread test/test_wigner_plotting.jl Outdated
# wigner is only defined for FockBasis states
b_spin = SpinBasis(1//2)
ψ_spin = spinup(b_spin)
@test_throws Exception wignerplot_axis(ψ_spin)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test checks for ANY exception, so it is not actually validating that you are getting the exception you are expecting. @test_throws supports using a substring of the error message as a quick way to provide more specificity, use that instead.

@Krastanov Krastanov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way the error messages are done is a step backwards -- use the approach we had discussed with error hints

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