Skip to content

Commit 52ffaaa

Browse files
committed
Fix deprecation warnings in test suite
This commit fixes deprecation warnings by updating the test suite to use the new Integrals.jl API: 1. Update `IntegralProblem(f, lb, ub, p)` to `IntegralProblem(f, (lb, ub), p)` - The domain should now be passed as a tuple (lb, ub) instead of separate arguments 2. Replace deprecated `batch` and `nout` keywords with new interfaces: - Replace `IntegralProblem(f, domain, batch=1000)` with `IntegralProblem(BatchIntegralFunction(f), domain)` - Replace `IntegralProblem(f, domain, nout=n)` with `IntegralProblem(IntegralFunction(f, zeros(n)), domain)` - For in-place batch functions, use proper prototype vectors (e.g., `zeros(0)` or `zeros(nout, 0)`) These changes eliminate all deprecation warnings from the test suite while maintaining full functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e057507 commit 52ffaaa

File tree

4 files changed

+36
-40
lines changed

4 files changed

+36
-40
lines changed

test/gaussian_quadrature_tests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ alg = GaussLegendre(nodes = nd, weights = wt, subintervals = 20)
4646
@test alg.subintervals == 20
4747

4848
f = (x, p) -> 5x + sin(x) - p * exp(x)
49-
prob = IntegralProblem(f, -5, 3, 3.3)
49+
prob = IntegralProblem(f, (-5, 3), 3.3)
5050
alg = GaussLegendre()
5151
sol = solve(prob, alg)
5252
@test isnothing(sol.chi)
@@ -60,7 +60,7 @@ sol = solve(prob, alg)
6060
@test sol.u -exp(3) * 3.3 + 3.3 / exp(5) - 40 + cos(5) - cos(3)
6161

6262
f = (x, p) -> exp(-x^2)
63-
prob = IntegralProblem(f, 0.0, Inf)
63+
prob = IntegralProblem(f, (0.0, Inf))
6464
alg = GaussLegendre()
6565
sol = solve(prob, alg)
6666
@test sol.u sqrt(π) / 2
@@ -69,7 +69,7 @@ alg = GaussLegendre(subintervals = 1)
6969
alg = GaussLegendre(subintervals = 17)
7070
@test sol.u sqrt(π) / 2
7171

72-
prob = IntegralProblem(f, -Inf, Inf)
72+
prob = IntegralProblem(f, (-Inf, Inf))
7373
alg = GaussLegendre()
7474
sol = solve(prob, alg)
7575
@test sol.u sqrt(π)
@@ -78,7 +78,7 @@ alg = GaussLegendre(subintervals = 1)
7878
alg = GaussLegendre(subintervals = 17)
7979
@test sol.u sqrt(π)
8080

81-
prob = IntegralProblem(f, -Inf, 0.0)
81+
prob = IntegralProblem(f, (-Inf, 0.0))
8282
alg = GaussLegendre()
8383
sol = solve(prob, alg)
8484
@test sol.u sqrt(π) / 2
@@ -90,7 +90,7 @@ alg = GaussLegendre(subintervals = 17)
9090
# Make sure broadcasting correctly handles the argument p
9191
f = (x, p) -> 1 + x + x^p[1] - cos(x * p[2]) + exp(x) * p[3]
9292
p = [0.3, 1.3, -0.5]
93-
prob = IntegralProblem(f, 2.0, 6.3, p)
93+
prob = IntegralProblem(f, (2.0, 6.3), p)
9494
alg = GaussLegendre()
9595
sol = solve(prob, alg)
9696
@test sol.u -240.25235266303063249920743158729

test/interface_tests.jl

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ end
103103
continue
104104
end
105105
for i in 1:length(integrands)
106-
prob = IntegralProblem(integrands[i], lb, ub)
106+
prob = IntegralProblem(integrands[i], (lb, ub))
107107
@info "Alg = $(nameof(typeof(alg))), Integrand = $i, Dimension = $dim, Output Dimension = $nout"
108108
sol = @inferred solve(prob, alg, reltol = reltol, abstol = abstol)
109109
@test sol.alg == alg
@@ -118,7 +118,7 @@ end
118118
for i in 1:length(integrands)
119119
for dim in 1:max_dim_test
120120
lb, ub = (ones(dim), 3ones(dim))
121-
prob = IntegralProblem(integrands[i], lb, ub)
121+
prob = IntegralProblem(integrands[i], (lb, ub))
122122
if dim > req.max_dim || dim < req.min_dim
123123
continue
124124
end
@@ -137,7 +137,7 @@ end
137137
for i in 1:length(iip_integrands)
138138
for dim in 1:max_dim_test
139139
lb, ub = (ones(dim), 3ones(dim))
140-
prob = IntegralProblem(iip_integrands[i], lb, ub)
140+
prob = IntegralProblem(iip_integrands[i], (lb, ub))
141141
if dim > req.max_dim || dim < req.min_dim || !req.allows_iip
142142
continue
143143
end
@@ -159,7 +159,7 @@ end
159159
(dim, nout) = (1, 1)
160160
for (alg, req) in pairs(alg_req)
161161
for i in 1:length(integrands)
162-
prob = IntegralProblem(batch_f(integrands[i]), lb, ub, batch = 1000)
162+
prob = IntegralProblem(BatchIntegralFunction(batch_f(integrands[i])), (lb, ub))
163163
if req.min_dim > 1 || !req.allows_batch
164164
continue
165165
end
@@ -177,7 +177,7 @@ end
177177
for i in 1:length(integrands)
178178
for dim in 1:max_dim_test
179179
(lb, ub) = (ones(dim), 3ones(dim))
180-
prob = IntegralProblem(batch_f(integrands[i]), lb, ub, batch = 1000)
180+
prob = IntegralProblem(BatchIntegralFunction(batch_f(integrands[i])), (lb, ub))
181181
if dim > req.max_dim || dim < req.min_dim || !req.allows_batch
182182
continue
183183
end
@@ -200,7 +200,7 @@ end
200200
for i in 1:length(iip_integrands)
201201
for dim in 1:max_dim_test
202202
(lb, ub) = (ones(dim), 3ones(dim))
203-
prob = IntegralProblem(batch_iip_f(integrands[i]), lb, ub, batch = 1000)
203+
prob = IntegralProblem(BatchIntegralFunction(batch_iip_f(integrands[i]), zeros(0)), (lb, ub))
204204
if dim > req.max_dim || dim < req.min_dim || !req.allows_batch ||
205205
!req.allows_iip
206206
continue
@@ -225,10 +225,10 @@ end
225225
for (alg, req) in pairs(alg_req)
226226
for i in 1:length(integrands_v)
227227
for nout in 1:max_nout_test
228-
prob = IntegralProblem(let f = integrands_v[i], nout = nout
229-
(x, p) -> f(x, p, nout)
230-
end, lb, ub,
231-
nout = nout)
228+
integrand_f = let f = integrands_v[i], nout = nout
229+
IntegralFunction((x, p) -> f(x, p, nout), zeros(nout))
230+
end
231+
prob = IntegralProblem(integrand_f, (lb, ub))
232232
if req.min_dim > 1 || req.nout < nout
233233
continue
234234
end
@@ -254,10 +254,10 @@ end
254254
if dim > req.max_dim || dim < req.min_dim || req.nout < nout
255255
continue
256256
end
257-
prob = IntegralProblem(let f = integrands_v[i], nout = nout
258-
(x, p) -> f(x, p, nout)
259-
end, lb, ub,
260-
nout = nout)
257+
integrand_f = let f = integrands_v[i], nout = nout
258+
IntegralFunction((x, p) -> f(x, p, nout), zeros(nout))
259+
end
260+
prob = IntegralProblem(integrand_f, (lb, ub))
261261
@info "Alg = $(nameof(typeof(alg))), Integrand = $i, Dimension = $dim, Output Dimension = $nout"
262262
sol = @inferred solve(prob, alg, reltol = reltol, abstol = abstol)
263263
@test sol.alg == alg
@@ -278,10 +278,10 @@ end
278278
for dim in 1:max_dim_test
279279
lb, ub = (ones(dim), 3ones(dim))
280280
for nout in 1:max_nout_test
281-
prob = IntegralProblem(let f = iip_integrands_v[i]
282-
(dx, x, p) -> f(dx, x, p, nout)
283-
end,
284-
lb, ub, nout = nout)
281+
integrand_f = let f = iip_integrands_v[i]
282+
IntegralFunction((dx, x, p) -> f(dx, x, p, nout), zeros(nout))
283+
end
284+
prob = IntegralProblem(integrand_f, (lb, ub))
285285
if dim > req.max_dim || dim < req.min_dim || req.nout < nout ||
286286
!req.allows_iip
287287
continue
@@ -305,8 +305,7 @@ end
305305
(dim, nout) = (1, 2)
306306
for (alg, req) in pairs(alg_req)
307307
for i in 1:length(integrands_v)
308-
prob = IntegralProblem(batch_f_v(integrands_v[i], nout), lb, ub, batch = 1000,
309-
nout = nout)
308+
prob = IntegralProblem(BatchIntegralFunction(batch_f_v(integrands_v[i], nout)), (lb, ub))
310309
if req.min_dim > 1 || !req.allows_batch || req.nout < nout
311310
continue
312311
end
@@ -324,9 +323,7 @@ end
324323
for i in 1:length(integrands_v)
325324
for dim in 1:max_dim_test
326325
(lb, ub) = (ones(dim), 3ones(dim))
327-
prob = IntegralProblem(batch_f_v(integrands_v[i], nout), lb, ub,
328-
batch = 1000,
329-
nout = nout)
326+
prob = IntegralProblem(BatchIntegralFunction(batch_f_v(integrands_v[i], nout)), (lb, ub))
330327
if dim > req.max_dim || dim < req.min_dim || !req.allows_batch ||
331328
req.nout < nout
332329
continue
@@ -346,8 +343,7 @@ end
346343
for i in 1:length(iip_integrands_v)
347344
for dim in 1:max_dim_test
348345
(lb, ub) = (ones(dim), 3ones(dim))
349-
prob = IntegralProblem(batch_iip_f_v(integrands_v[i], nout), lb, ub,
350-
batch = 10, nout = nout)
346+
prob = IntegralProblem(BatchIntegralFunction(batch_iip_f_v(integrands_v[i], nout), zeros(nout, 0)), (lb, ub))
351347
if dim > req.max_dim || dim < req.min_dim || !req.allows_batch ||
352348
!req.allows_iip || req.nout < nout
353349
continue
@@ -381,7 +377,7 @@ end
381377
continue
382378
end
383379
for i in 1:length(integrands)
384-
prob = IntegralProblem(integrands[i], lb, ub, p)
380+
prob = IntegralProblem(integrands[i], (lb, ub), p)
385381
cache = init(prob, alg, reltol = reltol, abstol = abstol)
386382
@test solve!(cache).uexact_sol[i](dim, nout, lb, ub) rtol=1e-2
387383
cache.lb = lb = 0.5

test/nested_ad_tests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Integrals, FiniteDiff, ForwardDiff, Cubature, Cuba, Zygote, Test
33
my_parameters = [1.0, 2.0]
44
my_function(x, p) = x^2 + p[1]^3 * x + p[2]^2
55
function my_integration(p)
6-
my_problem = IntegralProblem(my_function, -1.0, 1.0, p)
6+
my_problem = IntegralProblem(my_function, (-1.0, 1.0), p)
77
# return solve(my_problem, HCubatureJL(), reltol=1e-3, abstol=1e-3) # Works
88
return solve(my_problem, CubatureJLh(), reltol = 1e-3, abstol = 1e-3) # Errors
99
end
@@ -19,7 +19,7 @@ ub = 3ones(2)
1919
p = [1.5, 2.0]
2020

2121
function testf(p)
22-
prob = IntegralProblem(ff, lb, ub, p)
22+
prob = IntegralProblem(ff, (lb, ub), p)
2323
sin(solve(prob, CubaCuhre(), reltol = 1e-6, abstol = 1e-6)[1])
2424
end
2525

@@ -32,10 +32,10 @@ lb = 1.0
3232
ub = 3.0
3333
p = [2.0, 3.0, 4.0]
3434
_ff3 = BatchIntegralFunction(ff2)
35-
prob = IntegralProblem(_ff3, lb, ub, p)
35+
prob = IntegralProblem(_ff3, (lb, ub), p)
3636

3737
function testf3(lb, ub, p; f = _ff3)
38-
prob = IntegralProblem(_ff3, lb, ub, p)
38+
prob = IntegralProblem(_ff3, (lb, ub), p)
3939
solve(prob, CubatureJLh(); reltol = 1e-3, abstol = 1e-3)[1]
4040
end
4141

test/quadrule_tests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ lb = -1.2
3030
ub = 3.5
3131
p = 2.0
3232

33-
prob = IntegralProblem(f, lb, ub, p)
33+
prob = IntegralProblem(f, (lb, ub), p)
3434
u = solve(prob, alg).u
3535

3636
@test uexact_f(lb, ub, p) rtol=1e-3
@@ -49,7 +49,7 @@ lb = SVector(-1.2, -1.0)
4949
ub = SVector(3.5, 3.7)
5050
p = 1.2
5151

52-
prob = IntegralProblem(f, lb, ub, p)
52+
prob = IntegralProblem(f, (lb, ub), p)
5353
u = solve(prob, alg).u
5454

5555
@test uexact_f(lb, ub, p) rtol=1e-3
@@ -64,7 +64,7 @@ lb = -Inf
6464
ub = Inf
6565
p = 1.0
6666

67-
prob = IntegralProblem(g, lb, ub, p)
67+
prob = IntegralProblem(g, (lb, ub), p)
6868

6969
@test solve(prob, alg).upi rtol=1e-4
7070

@@ -78,7 +78,7 @@ lb = -Inf
7878
ub = Inf
7979
p = (1.0, 1.3)
8080

81-
prob = IntegralProblem(g2, lb, ub, p)
81+
prob = IntegralProblem(g2, (lb, ub), p)
8282

8383
@test solve(prob, alg).u[pi, pi] rtol=1e-4
8484

@@ -87,7 +87,7 @@ prob = IntegralProblem(g2, lb, ub, p)
8787
using Zygote
8888
8989
function testf(lb, ub, p, f = f)
90-
prob = IntegralProblem(f, lb, ub, p)
90+
prob = IntegralProblem(f, (lb, ub), p)
9191
solve(prob, QuadratureRule(trapz, n=200))[1]
9292
end
9393

0 commit comments

Comments
 (0)