Skip to content

Commit 752f44c

Browse files
committed
fix typo in docstrings
1 parent 0284136 commit 752f44c

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

docs/src/users_guide/plotting_the_bloch_sphere.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ At the end of the last section we saw that the colors and marker shapes of the d
174174
|:----------|:----------------|:--------------------|
175175
| `b.points` | Points to plot on the Bloch sphere (3D coordinates) | `Vector{Matrix{Float64}}()` (empty) |
176176
| `b.vectors` | Vectors to plot on the Bloch sphere | `Vector{Vector{Float64}}()` (empty) |
177-
| `b.lines` | Lines to draw on the sphere (points, style, properties) | `Vector{Tuple{Vector{Vector{Float64}},String}}()` (empty) |
177+
| `b.lines` | Lines to draw on the sphere with each line given as `([start_pt, end_pt], line_format)` | `Vector{Tuple{Vector{Vector{Float64}},String}}()` (empty) |
178178
| `b.arcs` | Arcs to draw on the sphere | `Vector{Vector{Vector{Float64}}}()` (empty) |
179179

180180
### Properties
@@ -195,7 +195,7 @@ At the end of the last section we saw that the colors and marker shapes of the d
195195
| `b.sphere_alpha` | Transparency of sphere surface | `"#FFDDDD"` |
196196
| `b.vector_color` | Colors for vectors | `["green", "#CC6600", "blue", "red"]` |
197197
| `b.vector_width` | Width of vectors | `0.025` |
198-
| `b.vector_arrowsize` | Arrow size parameters as (head length, head width, stem width) | `[0.07, 0.08, 0.08]` |
198+
| `b.vector_arrowsize` | Arrow size parameters as `[head_length, head_width, stem_width]` | `[0.07, 0.08, 0.08]` |
199199
| `b.view` | Azimuthal and elevation viewing angles in degrees | `[30, 30]` |
200200
| `b.xlabel` | Labels for x-axis | `[L"x", ""]` (``+x`` and ``-x``) |
201201
| `b.xlpos` | Positions of x-axis labels | `[1.2, -1.2]` |

ext/QuantumToolboxMakieExt.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ function QuantumToolbox.render(b::Bloch; location = nothing)
349349
_add_labels!(b, lscene)
350350

351351
# plot data fields in Bloch
352-
_plot_points!(b, lscene)
352+
_plot_vectors!(b, lscene)
353353
_plot_lines!(b, lscene)
354354
_plot_arcs!(b, lscene)
355-
_plot_vectors!(b, lscene)
355+
_plot_points!(b, lscene) # plot points at the end so that they will be on the very top (front) figure layer.
356356

357357
return fig, lscene
358358
end
@@ -523,6 +523,7 @@ Plot all quantum state points on the Bloch sphere.
523523
Handles both scatter points and line traces based on style specifications.
524524
"""
525525
function _plot_points!(b::Bloch, lscene)
526+
isempty(b.points) && return nothing
526527
for k in 1:length(b.points)
527528
pts = b.points[k]
528529
style = b.point_style[k]
@@ -596,6 +597,7 @@ Draw all connecting lines between points on the Bloch sphere.
596597
Processes line style specifications and color mappings.
597598
"""
598599
function _plot_lines!(b::Bloch, lscene)
600+
isempty(b.lines) && return nothing
599601
color_map =
600602
Dict("k" => :black, "r" => :red, "g" => :green, "b" => :blue, "c" => :cyan, "m" => :magenta, "y" => :yellow)
601603
for (line, fmt) in b.lines
@@ -628,6 +630,7 @@ Draw circular arcs connecting points on the Bloch sphere surface.
628630
Calculates great circle arcs between specified points.
629631
"""
630632
function _plot_arcs!(b::Bloch, lscene)
633+
isempty(b.arcs) && return nothing
631634
for arc_pts in b.arcs
632635
length(arc_pts) >= 2 || continue
633636
v1 = normalize(arc_pts[1])
@@ -657,22 +660,17 @@ Draw vectors from origin representing quantum states.
657660
Scales vectors appropriately and adds `3D` arrow markers.
658661
"""
659662
function _plot_vectors!(b::Bloch, lscene)
660-
isempty(b.vectors) && return
661-
arrowsize_vec = Vec3f(b.vector_arrowsize...)
662-
r = 1.0
663+
isempty(b.vectors) && return nothing
663664
for (i, v) in enumerate(b.vectors)
664665
color = get(b.vector_color, i, RGBAf(0.2, 0.5, 0.8, 0.9))
665-
vec = Vec3f(v...)
666-
length = norm(vec)
667-
max_length = r * 0.90
668-
vec = length > max_length ? (vec/length) * max_length : vec
666+
vec = 0.92 * Vec3f(v...) # multiply by 0.92 so that the point edge of the arrow represents the actual position
669667
arrows!(
670668
lscene,
671669
[Point3f(0, 0, 0)],
672670
[vec],
673671
color = color,
674672
linewidth = b.vector_width,
675-
arrowsize = arrowsize_vec,
673+
arrowsize = Vec3f(b.vector_arrowsize...),
676674
arrowcolor = color,
677675
rasterize = 3,
678676
)

src/visualization.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ A structure representing a Bloch sphere visualization for quantum states. Availa
7474
## Data storage
7575
- `points::Vector{Matrix{Float64}}`: Points to plot on the Bloch sphere (3D coordinates)
7676
- `vectors::Vector{Vector{Float64}}}`: Vectors to plot on the Bloch sphere
77-
- `lines::Vector{Tuple{Vector{Vector{Float64}},String,Dict{Any,Any}}}`: Lines to draw on the sphere (points, style, properties)
77+
- `lines::Vector{Tuple{Vector{Vector{Float64}},String}}`: Lines to draw on the sphere with each line given as `([start_pt, end_pt], line_format)`
7878
- `arcs::Vector{Vector{Vector{Float64}}}}`: Arcs to draw on the sphere
7979
8080
## Style properties
@@ -100,9 +100,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa
100100
101101
## Vector properties
102102
103-
- `vector_color`::Vector{String}: Colors for vectors
104-
- `vector_width`::Float64: Width of vectors
105-
- `vector_arrowsize`::Vector{Float64}: Arrow size parameters as [head length, head width, stem width]
103+
- `vector_color::Vector{String}`: Colors for vectors
104+
- `vector_width::Float64`: Width of vectors
105+
- `vector_arrowsize::Vector{Float64}`: Arrow size parameters as `[head_length, head_width, stem_width]`
106106
107107
## Layout properties
108108
@@ -203,29 +203,29 @@ Add a single point to the Bloch sphere visualization.
203203
204204
# Arguments
205205
- `b::Bloch`: The Bloch sphere object to modify
206-
- `pnt::Vector{Float64}`: A 3D point to add
206+
- `pnt::Vector{<:Real}`: A 3D point to add
207207
- `meth::Symbol=:s`: Display method (`:s` for single point, `:m` for multiple, `:l` for line)
208208
- `color`: Color of the point (defaults to first default color if nothing)
209209
- `alpha=1.0`: Transparency (`1.0` means opaque and `0.0` means transparent)
210210
"""
211-
function add_points!(b::Bloch, pnt::Vector{Float64}; meth::Symbol = :s, color = nothing, alpha = 1.0)
211+
function add_points!(b::Bloch, pnt::Vector{<:Real}; meth::Symbol = :s, color = nothing, alpha = 1.0)
212212
return add_points!(b, reshape(pnt, 3, 1); meth, color, alpha)
213213
end
214-
function add_points!(b::Bloch, pnts::Vector{Vector{Float64}}; meth::Symbol = :s, color = nothing, alpha = 1.0)
214+
function add_points!(b::Bloch, pnts::Vector{Vector{<:Real}}; meth::Symbol = :s, color = nothing, alpha = 1.0)
215215
return add_points!(b, Matrix(hcat(pnts...)'); meth, color, alpha)
216216
end
217217

218218
@doc raw"""
219-
add_points!(b::Bloch, pnts::Matrix{Float64}; meth::Symbol = :s, color = nothing, alpha = 1.0)
219+
add_points!(b::Bloch, pnts::Matrix{<:Real}; meth::Symbol = :s, color = nothing, alpha = 1.0)
220220
221221
Add multiple points to the Bloch sphere visualization.
222222
223223
# Arguments
224224
225225
- `b::Bloch`: The Bloch sphere object to modify
226-
- `pnts::Matrix{Float64}`: `3×N` matrix of points (each column is a point)
226+
- `pnts::Matrix{<:Real}`: `3×N` matrix of points (each column is a point)
227227
- `meth::Symbol=:s`: Display method (`:s` for single point, `:m` for multiple, `:l` for line)
228-
- `color`: Color of the points (defaults to first default color if nothing)
228+
- `color`: Color of the points (defaults to first default color if `nothing`)
229229
- `alpha=1.0`: Transparency (`1.0` means opaque and `0.0` means transparent)
230230
```
231231
"""

0 commit comments

Comments
 (0)