Skip to content

Commit 2542fbb

Browse files
committed
add codereview suggestions
1 parent e6d93bb commit 2542fbb

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

ext/QuantumToolboxMakieExt.jl

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -782,20 +782,6 @@ function _plot_vectors!(b::Bloch, ax)
782782
end
783783
end
784784

785-
function _tolatex(s)
786-
s == "x" && return L"\textbf{x}"
787-
s == "y" && return L"\textbf{y}"
788-
s == "z" && return L"\textbf{z}"
789-
s == "-x" && return L"\textbf{-x}"
790-
s == "-y" && return L"\textbf{-y}"
791-
s == "-z" && return L"\textbf{-z}"
792-
s == "|0⟩" && return L"\mathbf{|0\rangle}"
793-
s == "|1⟩" && return L"\mathbf{|1\rangle}"
794-
return s
795-
end
796-
797-
_lerp(a::Float64, b::Float64, t::Float64) = a + t * (b - a)
798-
799785
raw"""
800786
_add_labels!(ax)
801787
@@ -809,71 +795,64 @@ Positions standard labels `(x, y, |0⟩, |1⟩)` at appropriate locations.
809795
function _add_labels!(b::Bloch, ax)
810796
label_color = parse(RGBf, b.font_color)
811797
label_size = b.font_size
812-
label_font = b.font_name
813798
offset_scale = b.frame_limit
814799
if !isempty(b.xlabel) && !isempty(b.xlabel[1])
815800
text!(
816801
ax,
817-
_tolatex(b.xlabel[1]),
802+
L"\textbf{x}",
818803
position = Point3f(0, -offset_scale * b.xlpos[1], 0),
819804
color = label_color,
820805
fontsize = label_size,
821-
font = label_font,
822806
align = (:center, :center)
823807
)
824808
end
825809
if length(b.xlabel) > 1 && !isempty(b.xlabel[2])
826810
text!(
827811
ax,
828-
_tolatex(b.xlabel[2]),
812+
L"\textbf{-x}",
829813
position = Point3f(0, -offset_scale * b.xlpos[2], 0),
830814
color = label_color,
831815
fontsize = label_size,
832-
font = label_font,
833816
align = (:center, :center)
834817
)
835818
end
836819
if !isempty(b.ylabel) && !isempty(b.ylabel[1])
837820
text!(
838821
ax,
839-
_tolatex(b.ylabel[1]),
822+
L"\textbf{y}",
840823
position = Point3f(offset_scale * b.ylpos[1], 0, 0),
841824
color = label_color,
842825
fontsize = label_size,
843-
font = label_font,
844826
align = (:center, :center)
845827
)
846828
end
847829
if length(b.ylabel) > 1 && !isempty(b.ylabel[2])
848830
text!(
849831
ax,
850-
_tolatex(b.ylabel[2]),
832+
L"\textbf{-y}",
851833
position = Point3f(offset_scale * b.ylpos[2], 0, 0),
852834
color = label_color,
853835
fontsize = label_size,
854-
font = label_font,
855836
align = (:center, :center)
856837
)
857838
end
858839
if !isempty(b.zlabel) && !isempty(b.zlabel[1])
859840
text!(
860841
ax,
861-
_tolatex(b.zlabel[1]),
842+
L"\mathbf{|0\rangle}",
862843
position = Point3f(0, 0, offset_scale * b.zlpos[1]),
863844
color = label_color,
864845
fontsize = label_size,
865-
font = label_font,
866846
align = (:center, :center)
867847
)
868848
end
869849
if length(b.zlabel) > 1 && !isempty(b.zlabel[2])
870850
text!(
871851
ax,
872-
_tolatex(b.zlabel[2]),
852+
L"\mathbf{|1\rangle}",
873853
position = Point3f(0, 0, offset_scale * b.zlpos[2]),
874854
color = label_color,
875855
fontsize = label_size,
876-
font = label_font,
877856
align = (:center, :center)
878857
)
879858
end

src/visualization.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ A structure representing a Bloch sphere visualization for quantum states.
8989
9090
- `font_color::String`: Color of axis labels and text
9191
- `font_size::Int`: Font size for labels (default: 18)
92-
- `font_name::String`: Font family name (default: "TeX Gyre Heros")
9392
- `frame_alpha::Float64`: Transparency of the frame background
9493
- `frame_color::String`: Background color of the frame
9594
- `frame_limit::Float64`: Axis limits for the 3D frame (symmetric around origin)
@@ -133,7 +132,6 @@ A structure representing a Bloch sphere visualization for quantum states.
133132
arcs::Vector{Vector{Vector{Float64}}} = Vector{Vector{Vector{Float64}}}()
134133
font_color::String = "#333333"
135134
font_size::Int = 15
136-
font_name::String = "Ariel"
137135
frame_alpha::Float64 = 0.0
138136
frame_color::String = "white"
139137
frame_limit::Float64 = 1.13
@@ -149,11 +147,11 @@ A structure representing a Bloch sphere visualization for quantum states.
149147
vector_width::Float64 = 0.025
150148
vector_arrowsize::NTuple{3,Real} = (0.07, 0.08, 0.08)
151149
view_angles::Tuple{Int,Int} = (-60, 30)
152-
xlabel::Vector{String} = ["x", ""]
150+
xlabel::Vector{AbstractString} = ["x", ""]
153151
xlpos::Vector{Float64} = [1.0, -1.0]
154-
ylabel::Vector{String} = ["y", ""]
152+
ylabel::Vector{AbstractString} = ["y", ""]
155153
ylpos::Vector{Float64} = [1.0, -1.0]
156-
zlabel::Vector{String} = ["|0⟩", "|1⟩"]
154+
zlabel::Vector{AbstractString} = ["|0⟩", "|1⟩"]
157155
zlpos::Vector{Float64} = [1.0, -1.0]
158156
end
159157

0 commit comments

Comments
 (0)