@@ -4,6 +4,7 @@ using DataInterpolations: integral
44using Optim, ForwardDiff
55using RegularizationTools
66using StableRNGs
7+ using Unitful
78
89function test_integral (method; args = [], kwargs = [], name:: String )
910 func = method (args... ; kwargs... , extrapolation_left = ExtrapolationType. Extension,
213214 @test_throws DataInterpolations. IntegralNotFoundError integral (A, 1.0 , 100.0 )
214215 @test_throws DataInterpolations. IntegralNotFoundError integral (A, 50.0 )
215216end
217+
218+ # issue #385
219+ @testset " Integrals with unitful numbers" begin
220+ u = rand (5 )u " m"
221+ A = ConstantInterpolation (u, (1 : 5 )u " s" )
222+ @test @inferred (integral (A, 4 u " s" )) ≈ sum (u[1 : 3 ]) * u " s"
223+ end
224+
225+ @testset " cumulative_integral" begin
226+ A = ConstantInterpolation ([" A" , " B" , " C" ], [0.0 , 0.25 , 0.75 ])
227+ for cache_parameter in (true , false )
228+ @test @inferred (DataInterpolations. cumulative_integral (A, cache_parameter)) ===
229+ nothing
230+ end
231+
232+ A = ConstantInterpolation ([3.1 , 2.5 , 4.7 ], [0.0 , 0.25 , 0.75 ])
233+ @test @inferred (DataInterpolations. cumulative_integral (A, false )) == Float64[]
234+ @test @inferred (DataInterpolations. cumulative_integral (A, true )) == [0.775 , 2.025 ]
235+ end
0 commit comments