-
Notifications
You must be signed in to change notification settings - Fork 47
Add Wigner function computation and Makie visualization extension #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Aniket-umass
wants to merge
16
commits into
qojulia:master
Choose a base branch
from
Aniket-umass:makie-wigner-extension
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
906ed47
Add Makie Bloch sphere extension using Ket and update Project.toml
Aniket-umass b2b44c3
Add Wigner function computation and Makie visualization extension
Aniket-umass b42ab39
Revert phasespace.jl to master - wigner computation already exists up…
Aniket-umass 7d47f21
Restore Project.toml to master
Aniket-umass 5ca822c
Add Makie weakdep and extension to Project.toml
Aniket-umass 62329db
Remove blochsphere stub
Aniket-umass ba6c6cb
Merge branch 'master' into makie-wigner-extension
Aniket-umass 355dbe4
Fix CI: remove bloch sphere leftovers, fix exports, fix test types
Aniket-umass 24d8b03
Fix CI: remove bloch sphere leftovers, fix exports, fix test types
Aniket-umass f4ff9b9
Fix Wigner PR: preserve Bloch sphere code, fix imports and exports
Aniket-umass 338ae1c
Fix Wigner PR: preserve Bloch sphere code, fix imports and exports
Aniket-umass aa112c2
Add basis validation and Makie backend error hints
Aniket-umass e073f20
Merge upstream/master to pick up CI updates
Aniket-umass b4c63ea
Use register_error_hint for Makie backend hints
Aniket-umass 9dd6a43
Use WeakDepHelpers for Makie backend error hints
Aniket-umass f402d95
Merge branch 'master' into makie-wigner-extension
Aniket-umass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| @testitem "Wigner Plot" tags=[:plotting] begin | ||
| using QuantumOpticsBase | ||
| using QuantumOptics | ||
| using CairoMakie | ||
|
|
||
| b = FockBasis(10) # truncated Fock space — adequate for coherent α≤2, Fock n≤3 | ||
|
|
||
| # ── Return types ────────────────────────────────────────────────────────── | ||
| @testset "wignerplot_axis returns Figure, Axis, and plot object" begin | ||
| ψ = coherentstate(b, 1.0) | ||
| fig, ax, plt = wignerplot_axis(ψ) | ||
| @test fig isa Figure | ||
| @test ax isa Axis | ||
| @test plt isa AbstractPlot | ||
| end | ||
|
|
||
| # ── Render tests ────────────────────────────────────────────────────────── | ||
| @testset "coherent state renders without error" begin | ||
| ψ = coherentstate(b, 2.0) | ||
| fig, _, _ = wignerplot_axis(ψ) | ||
| save("test_wigner_coherent.png", fig) | ||
| @test isfile("test_wigner_coherent.png") | ||
| rm("test_wigner_coherent.png") | ||
| end | ||
|
|
||
| @testset "Fock state renders without error (Wigner can go negative)" begin | ||
| ψ = fockstate(b, 3) | ||
| fig, _, _ = wignerplot_axis(ψ) | ||
| save("test_wigner_fock.png", fig) | ||
| @test isfile("test_wigner_fock.png") | ||
| rm("test_wigner_fock.png") | ||
| end | ||
|
|
||
| # ── Custom attributes ───────────────────────────────────────────────────── | ||
| @testset "Custom xrange, prange, npoints" begin | ||
| ψ = coherentstate(b, 0.5) | ||
| fig, _, _ = wignerplot_axis(ψ; xrange=(-3.0, 3.0), prange=(-3.0, 3.0), npoints=50) | ||
| save("test_wigner_custom_range.png", fig) | ||
| @test isfile("test_wigner_custom_range.png") | ||
| rm("test_wigner_custom_range.png") | ||
| end | ||
|
|
||
| @testset "Custom colormap" begin | ||
| ψ = coherentstate(b, 1.0) | ||
| fig, _, _ = wignerplot_axis(ψ; colormap=:bwr) | ||
| save("test_wigner_custom_colormap.png", fig) | ||
| @test isfile("test_wigner_custom_colormap.png") | ||
| rm("test_wigner_custom_colormap.png") | ||
| end | ||
|
|
||
| # ── Observable reactivity ───────────────────────────────────────────────── | ||
| @testset "Observable state updates reactively" begin | ||
| using Makie: Observable | ||
| state_obs = Observable(coherentstate(b, 1.0)) | ||
| fig, ax, _ = wignerplot_axis(state_obs) | ||
| state_obs[] = coherentstate(b, -1.0) # shift coherent peak to opposite side | ||
| save("test_wigner_observable.png", fig) | ||
| @test isfile("test_wigner_observable.png") | ||
| rm("test_wigner_observable.png") | ||
| end | ||
|
|
||
| # ── Error handling ──────────────────────────────────────────────────────── | ||
| @testset "Wrong basis type throws error" begin | ||
| # wigner is only defined for FockBasis states | ||
| b_spin = SpinBasis(1//2) | ||
| ψ_spin = spinup(b_spin) | ||
| @test_throws "FockBasis" wignerplot_axis(ψ_spin) | ||
| end | ||
| end |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use WeakDepHelpers.jl, do not reimplement it.