|
63 | 63 | end |
64 | 64 |
|
65 | 65 |
|
| 66 | +@testset "Vector{Float64} conversion" begin |
| 67 | + tlist = collect(range(0, 10, length = 101)) |
| 68 | + S(t) = flattop(t, T = 10, t_rise = 2, func = :blackman) |
| 69 | + ϵ(t) = 1.0 |
| 70 | + |
| 71 | + # LockedAmplitude: callable returning Int is discretized to Vector{Float64} |
| 72 | + ampl = LockedAmplitude(t -> 1, tlist) |
| 73 | + @test ampl.shape isa Vector{Float64} |
| 74 | + @test check_amplitude(ampl; tlist) |
| 75 | + |
| 76 | + # LockedAmplitude: Vector{Int} is converted to Vector{Float64} |
| 77 | + S_int = ones(Int, length(tlist) - 1) |
| 78 | + ampl = LockedAmplitude(S_int) |
| 79 | + @test ampl.shape isa Vector{Float64} |
| 80 | + @test check_amplitude(ampl; tlist) |
| 81 | + |
| 82 | + # ShapedAmplitude: callable shape returning Int |
| 83 | + ampl = ShapedAmplitude(ϵ; shape = t -> 1) |
| 84 | + @test check_amplitude(ampl; tlist) |
| 85 | + t = t_mid(tlist, 20) |
| 86 | + @test evaluate(ampl, tlist, 20) ≈ ϵ(t) * 1 |
| 87 | + |
| 88 | + # ShapedAmplitude: Vector{Int} control and shape are converted |
| 89 | + ϵ_int = ones(Int, length(tlist) - 1) |
| 90 | + S_int = ones(Int, length(tlist) - 1) |
| 91 | + ampl = ShapedAmplitude(ϵ_int; shape = S_int) |
| 92 | + @test ampl.control isa Vector{Float64} |
| 93 | + @test ampl.shape isa Vector{Float64} |
| 94 | + @test check_amplitude(ampl; tlist) |
| 95 | + |
| 96 | + # ShapedAmplitude tlist constructor: callable returning Int is discretized to Vector{Float64} |
| 97 | + ampl = ShapedAmplitude(t -> 1, tlist; shape = t -> 1) |
| 98 | + @test ampl.control isa Vector{Float64} |
| 99 | + @test ampl.shape isa Vector{Float64} |
| 100 | + |
| 101 | +end |
| 102 | + |
| 103 | + |
66 | 104 | @testset "ShapedAmplitude mixed" begin |
67 | 105 | tlist = collect(range(0, 10, length = 101)) |
68 | 106 | S(t) = flattop(t, T = 10, t_rise = 2, func = :blackman) |
|
0 commit comments