Skip to content

Commit c6283fe

Browse files
github-actions[bot]CompatHelper Juliaalbertomercurio
authored
CompatHelper: bump compat for Makie in [weakdeps] to 0.24 (#513)
Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Alberto Mercurio <[email protected]>
1 parent e2c6d3e commit c6283fe

File tree

6 files changed

+20
-26
lines changed

6 files changed

+20
-26
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- Improve efficiency of `bloch_redfield_tensor` by avoiding unnecessary conversions. ([#509])
1111
- Support `SciMLOperators v1.4+`. ([#470])
12+
- Fix compatibility with `Makie v0.24+`. ([#513])
1213

1314
## [v0.33.0]
1415
Release date: 2025-07-22
@@ -272,3 +273,4 @@ Release date: 2024-11-13
272273
[#506]: https://github.com/qutip/QuantumToolbox.jl/issues/506
273274
[#507]: https://github.com/qutip/QuantumToolbox.jl/issues/507
274275
[#509]: https://github.com/qutip/QuantumToolbox.jl/issues/509
276+
[#513]: https://github.com/qutip/QuantumToolbox.jl/issues/513

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ KernelAbstractions = "0.9.2"
5555
LaTeXStrings = "1.2"
5656
LinearAlgebra = "1"
5757
LinearSolve = "2, 3"
58-
Makie = "0.20, 0.21, 0.22, 0.23"
58+
Makie = "0.24"
5959
OrdinaryDiffEqCore = "1"
6060
OrdinaryDiffEqTsit5 = "1"
6161
Pkg = "1"

docs/src/users_guide/plotting_the_bloch_sphere.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ At the end of the last section we saw that the colors and marker shapes of the d
195195
| `b.sphere_color` | Color of Bloch sphere surface | `0.2` |
196196
| `b.sphere_alpha` | Transparency of sphere surface | `"#FFDDDD"` |
197197
| `b.vector_color` | Colors for vectors | `["green", "#CC6600", "blue", "red"]` |
198-
| `b.vector_width` | Width of vectors | `0.025` |
199-
| `b.vector_arrowsize` | Scales the size of the arrow head. The first two elements scale the radius (in `x/y` direction) and the last one is the length of the cone. | `[0.07, 0.08, 0.08]` |
198+
| `b.vector_width` | Width of vectors | `0.02` |
199+
| `b.vector_tiplength` | Length of vector arrow head | `0.08` |
200+
| `b.vector_tipradius` | Radius of vector arrow head | `0.05` |
200201
| `b.view` | Azimuthal and elevation viewing angles in degrees | `[30, 30]` |
201202
| `b.xlabel` | Labels for x-axis | `[L"x", ""]` (``+x`` and ``-x``) |
202203
| `b.xlpos` | Positions of x-axis labels | `[1.2, -1.2]` |

ext/QuantumToolboxMakieExt.jl

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Makie:
2222
Sphere,
2323
lines!,
2424
scatter!,
25-
arrows!,
25+
arrows3d!,
2626
text!,
2727
Point3f,
2828
mesh!,
@@ -656,26 +656,17 @@ Scales vectors appropriately and adds `3D` arrow markers.
656656
function _plot_vectors!(b::Bloch, lscene)
657657
isempty(b.vectors) && return nothing
658658

659-
arrow_head_length = b.vector_arrowsize[3]
660659
for (i, v) in enumerate(b.vectors)
661660
color = get(b.vector_color, i, RGBAf(0.2, 0.5, 0.8, 0.9))
662-
nv = norm(v)
663-
(arrow_head_length < nv) || throw(
664-
ArgumentError(
665-
"The length of vector arrow head (Bloch.vector_arrowsize[3]=$arrow_head_length) should be shorter than vector norm: $nv",
666-
),
667-
)
668661

669-
# multiply by the following factor makes the end point of arrow head represent the actual vector position.
670-
vec = (1 - arrow_head_length / nv) * Vec3f(v...)
671-
arrows!(
662+
arrows3d!(
672663
lscene,
673664
[Point3f(0, 0, 0)],
674-
[vec],
665+
[v],
675666
color = color,
676-
linewidth = b.vector_width,
677-
arrowsize = Vec3f(b.vector_arrowsize...),
678-
arrowcolor = color,
667+
shaftradius = b.vector_width,
668+
tiplength = b.vector_tiplength,
669+
tipradius = b.vector_tipradius,
679670
rasterize = 3,
680671
)
681672
end

src/visualization.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa
102102
## Vector properties
103103
104104
- `vector_color::Vector{String}`: Colors for vectors. Default: `["green", "#CC6600", "blue", "red"]`
105-
- `vector_width::Float64`: Width of vectors. Default: `0.025`
106-
- `vector_arrowsize::Vector{Float64}`: Scales the size of the arrow head. The first two elements scale the radius (in `x/y` direction) and the last one is the length of the cone. Default: `[0.07, 0.08, 0.08]`
105+
- `vector_width::Float64`: Width of vectors. Default: `0.02`
106+
- `vector_tiplength::Float64`: Length of vector arrow head. Default: `0.08`
107+
- `vector_tipradius::Float64`: Radius of vector arrow head. Default: `0.05`
107108
108109
## Layout properties
109110
@@ -137,8 +138,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa
137138
sphere_alpha::Float64 = 0.2
138139
sphere_color::String = "#FFDDDD"
139140
vector_color::Vector{String} = ["green", "#CC6600", "blue", "red"]
140-
vector_width::Float64 = 0.025
141-
vector_arrowsize::Vector{Float64} = [0.07, 0.08, 0.08]
141+
vector_width::Float64 = 0.02
142+
vector_tiplength::Float64 = 0.08
143+
vector_tipradius::Float64 = 0.05
142144
view::Vector{Int} = [30, 30]
143145
xlabel::Vector{AbstractString} = [L"x", ""]
144146
xlpos::Vector{Float64} = [1.2, -1.2]

test/ext-test/cpu/makie/makie_ext.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
@test fig isa Figure
1616
@test ax isa Axis
1717
@test hm isa Heatmap
18-
@test all(isapprox.(hm[3].val, wig, atol = 1e-6))
18+
@test all(isapprox.(hm[3].value.x, wig, atol = 1e-6))
1919

2020
fig, ax, surf =
2121
plot_wigner(ψ; library = Val(:Makie), xvec = xvec, yvec = yvec, projection = Val(:three_dim), colorbar = true)
2222
@test fig isa Figure
2323
@test ax isa Axis3
2424
@test surf isa Surface
25-
@test all(isapprox.(surf[3].val, wig, atol = 1e-6))
25+
@test all(isapprox.(surf[3].value.x, wig, atol = 1e-6))
2626

2727
fig = Figure()
2828
pos = fig[2, 3]
@@ -150,8 +150,6 @@ end
150150
@test false
151151
@info "Render threw unexpected error" exception=e
152152
end
153-
b.vector_arrowsize = [0.7, 0.8, 1.5] # 1.5 is the length of arrow head (too long)
154-
@test_throws ArgumentError render(b)
155153

156154
b = Bloch()
157155
ψ₁ = normalize(basis(2, 0) + basis(2, 1))

0 commit comments

Comments
 (0)