Skip to content

Commit 9ba72f8

Browse files
authored
fix dispatch issues (#40)
1 parent c38ec1c commit 9ba72f8

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/NumericalIntegration.jl

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const HALF = 1//2
3333
3434
Compute numerical integral of y(x) from x=x[1] to x=x[end]. Return a scalar of the same type as the input. If no method is supplied, use Trapezdoial.
3535
"""
36-
function integrate(x,y...) end
36+
function integrate end
3737

3838

3939
"""
@@ -330,18 +330,7 @@ function cumul_integrate(x::AbstractVector, y::AbstractMatrix, M::IntegrationMet
330330
end
331331

332332
#default behaviour
333-
integrate(x::AbstractVector, y::AbstractVector) = integrate(x, y, Trapezoidal())
334-
335-
function integrate(x::AbstractVector, y::AbstractMatrix; kwargs...)
336-
return integrate(x, y, Trapezoidal(); kwargs...)
337-
end
338-
339-
integrate(X::NTuple, Y::AbstractArray) = integrate(X, Y, Trapezoidal())
340-
341-
cumul_integrate(x::AbstractVector, y::AbstractVector) = cumul_integrate(x, y, Trapezoidal())
342-
343-
function cumul_integrate(x::AbstractVector, y::AbstractMatrix; kwargs...)
344-
return cumul_integrate(x, y, Trapezoidal(); kwargs...)
345-
end
333+
integrate(x, y; kwargs...) = integrate(x, y, Trapezoidal(); kwargs...)
334+
cumul_integrate(x, y; kwargs...) = cumul_integrate(x, y, Trapezoidal(); kwargs...)
346335

347336
end # module

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ end
5454
end
5555

5656
@test isapprox(integrate((X,Y,Z),A), hcubature(f,[0,-π,0],[2π,π,2])[1], atol=1e-4)
57+
58+
X = range(-π/2,stop=π/2,length=10)
59+
Y = sin.(X)
60+
ω = [x * y for x in X, y in Y]
61+
res = integrate((X, Y), ω)
62+
@test typeof(res) == Float64
5763
end
5864

5965
@testset "SVector" begin

0 commit comments

Comments
 (0)