From d1f32c2f799c998e3a534d10f7aaa5847f91ae58 Mon Sep 17 00:00:00 2001 From: John Long Date: Tue, 22 Aug 2023 09:10:07 -0700 Subject: [PATCH] Fix failing unit tests on Github CI due to warning from LinearInterpolation, also removed unnecessary variables in tests (#591) --- lib/BloqadeWaveforms/src/waveform.jl | 2 +- lib/BloqadeWaveforms/test/interpolate.jl | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/BloqadeWaveforms/src/waveform.jl b/lib/BloqadeWaveforms/src/waveform.jl index e3c054cb0..0f13c6ecf 100644 --- a/lib/BloqadeWaveforms/src/waveform.jl +++ b/lib/BloqadeWaveforms/src/waveform.jl @@ -302,7 +302,7 @@ struct PiecewiseLinear{T<:Real,Interp} length(clocks) == length(values) || throw(ArgumentError("clocks must have the same length as values")) T = promote_type(eltype(clocks), eltype(values)) clocks = Vector{T}(clocks); values = Vector{T}(values); - interp = LinearInterpolation(clocks, values) + interp = linear_interpolation(clocks, values) return new{eltype(values),typeof(interp)}(clocks, values, interp) end end diff --git a/lib/BloqadeWaveforms/test/interpolate.jl b/lib/BloqadeWaveforms/test/interpolate.jl index d47ee3041..4847de623 100644 --- a/lib/BloqadeWaveforms/test/interpolate.jl +++ b/lib/BloqadeWaveforms/test/interpolate.jl @@ -63,7 +63,6 @@ benchmark_func([1.0,-1.0,1.0]) end wf = Waveform(t->t^2,2) - @test_logs (:warn,warn_msg) piecewise_linear_interpolate(wf;atol=-1e-5) @test_throws ErrorException piecewise_linear_interpolate(wf;min_step = 0.1) @test_throws ErrorException piecewise_linear_interpolate(wf;atol=0) @@ -75,7 +74,6 @@ benchmark_func([1.0,-1.0,1.0]) new_wf = piecewise_constant_interpolate(wf) @test wf == new_wf - step_msg = "Waveform step smaller than constraint." @test_logs (:warn,warn_msg) piecewise_constant_interpolate(wf;atol=-1e-2) @test_throws ErrorException piecewise_constant_interpolate(wf;atol=0) @test_throws ErrorException piecewise_constant_interpolate(wf;min_step=3.0) @@ -88,8 +86,6 @@ end new_wf = piecewise_linear_interpolate(wf) @test wf == new_wf - slope_msg = "Waveform slope larger than constraint." - step_msg = "Waveform step smaller than constraint." # test_log instead of test_warn for julia 1.6 @test_logs (:warn,warn_msg) piecewise_linear_interpolate(wf;atol=-1e-3) @test_throws ErrorException piecewise_linear_interpolate(wf;atol=0) @@ -101,8 +97,6 @@ end @testset "piecewise constant waveforms" begin wf = piecewise_constant(;clocks = [0.0, 2.0, 3.0, 4.0], values = [0.0, 2.0, 1.0]) - pwc_step_msg = "Distance between steps in piecewise constant waveform are too small to convert to piecewise linear." - new_wf = piecewise_linear_interpolate(wf,atol=1e-3) # no constraints @test new_wf == piecewise_linear( clocks=[0.0,1.9995,2.0005,2.999,3.001,4.0],