Skip to content

Commit 55fc7d6

Browse files
committed
ensure unit gets applied in ordinary case
1 parent abcc700 commit 55fc7d6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/adapt.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function handle_infinities(workfunc, f, s)
147147
end
148148
end
149149
end
150-
I, E = workfunc(f, map(x -> x/oneunit(x), s), identity)
150+
I, E = workfunc(t -> f(t*u), map(x -> x/oneunit(x), s), identity)
151151
return u * I, u * E
152152
end
153153

@@ -185,7 +185,7 @@ function handle_infinities(workfunc, f::InplaceIntegrand, s)
185185
end
186186
end
187187
end
188-
I, E = workfunc(InplaceIntegrand(f.f!, f.fg, f.fk, f.Ig, f.Ik, f.fx, f.Idiff, similar(f.fx)),
188+
I, E = workfunc(InplaceIntegrand((y,t) -> f.f!(y, t*u), f.fg, f.fk, f.Ig, f.Ik, f.fx, f.Idiff, similar(f.fx)),
189189
map(x -> x/oneunit(x), s),
190190
identity)
191191
result .= u .* I

test/runtests.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ module Test19626
6969
ulims = map(x -> map(MockQuantity, x), lims)
7070
for (lb, ub) in ulims
7171
## function
72-
f = x -> 1/(1+(x/oneunit(x))^2)
72+
f = x -> 1/(1+(x/MockQuantity(1.0))^2)
7373
buf = QuadGK.alloc_segbuf(MockQuantity, Float64, MockQuantity)
7474
@test QuadGK.quadgk(f, lb, ub, atol=MockQuantity(0.0))[1]
7575
QuadGK.quadgk(f, lb, ub, atol=MockQuantity(0.0), segbuf=buf)[1]
7676
## inplace
77-
fiip = (y, x) -> y[1] = 1/(1+(x/oneunit(x))^2)
77+
fiip = (y, x) -> y[1] = 1/(1+(x/MockQuantity(1.0))^2)
7878
ibuf = QuadGK.alloc_segbuf(MockQuantity, Array{Float64,1}, MockQuantity)
7979
@test QuadGK.quadgk!(fiip, [MockQuantity(0.0)], lb, ub, atol=MockQuantity(0.0), norm=absfirst)[1][]
8080
QuadGK.quadgk!(fiip, [MockQuantity(0.0)], lb, ub, atol=MockQuantity(0.0), norm=absgetindex, segbuf=ibuf)[1][]
8181
## batch
82-
fbatch = BatchIntegrand{Float64}((y, x) -> y .= 1 ./ (1 .+ (x ./ oneunit.(x)) .^ 2))
82+
fbatch = BatchIntegrand{Float64}((y, x) -> y .= 1 ./ (1 .+ (x ./ MockQuantity(1.0)) .^ 2))
8383
@test QuadGK.quadgk(fbatch, lb, ub, atol=MockQuantity(0.0))[1]
8484
QuadGK.quadgk(fbatch, lb, ub, atol=MockQuantity(0.0), segbuf=buf)[1]
8585
end

0 commit comments

Comments
 (0)