Skip to content

Commit

Permalink
Fix failing unit tests on Github CI due to warning from LinearInterpo…
Browse files Browse the repository at this point in the history
…lation, also removed unnecessary variables in tests (#591)
  • Loading branch information
johnzl-777 authored Aug 22, 2023
1 parent 8f54a03 commit d1f32c2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion lib/BloqadeWaveforms/src/waveform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions lib/BloqadeWaveforms/test/interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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],
Expand Down

0 comments on commit d1f32c2

Please sign in to comment.