Skip to content

Commit bfd48b5

Browse files
committed
ensure unit gets applied in ordinary case
1 parent 119956d commit bfd48b5

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
@@ -72,17 +72,17 @@ module Test19626
7272
ulims = map(x -> map(MockQuantity, x), lims)
7373
for (lb, ub) in ulims
7474
## function
75-
f = x -> 1/(1+(x/oneunit(x))^2)
75+
f = x -> 1/(1+(x/MockQuantity(1.0))^2)
7676
buf = QuadGK.alloc_segbuf(MockQuantity, Float64, MockQuantity)
7777
@test QuadGK.quadgk(f, lb, ub, atol=MockQuantity(0.0))[1]
7878
QuadGK.quadgk(f, lb, ub, atol=MockQuantity(0.0), segbuf=buf)[1]
7979
## inplace
80-
fiip = (y, x) -> y[1] = 1/(1+(x/oneunit(x))^2)
80+
fiip = (y, x) -> y[1] = 1/(1+(x/MockQuantity(1.0))^2)
8181
ibuf = QuadGK.alloc_segbuf(MockQuantity, Array{Float64,1}, MockQuantity)
8282
@test QuadGK.quadgk!(fiip, [MockQuantity(0.0)], lb, ub, atol=MockQuantity(0.0), norm=absfirst)[1][]
8383
QuadGK.quadgk!(fiip, [MockQuantity(0.0)], lb, ub, atol=MockQuantity(0.0), norm=absgetindex, segbuf=ibuf)[1][]
8484
## batch
85-
fbatch = BatchIntegrand{Float64}((y, x) -> y .= 1 ./ (1 .+ (x ./ oneunit.(x)) .^ 2))
85+
fbatch = BatchIntegrand{Float64}((y, x) -> y .= 1 ./ (1 .+ (x ./ MockQuantity(1.0)) .^ 2))
8686
@test QuadGK.quadgk(fbatch, lb, ub, atol=MockQuantity(0.0))[1]
8787
QuadGK.quadgk(fbatch, lb, ub, atol=MockQuantity(0.0), segbuf=buf)[1]
8888
end

0 commit comments

Comments
 (0)