Skip to content

Commit 5019637

Browse files
committed
Renamed tests (Issue #2197)
1 parent f84f7eb commit 5019637

File tree

2 files changed

+67
-67
lines changed

2 files changed

+67
-67
lines changed

test/unit/math/prim/functor/integrate_1d_new_test.cpp renamed to test/unit/math/prim/functor/integrate_1d_impl_test.cpp

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <sstream>
77
#include <vector>
88

9-
namespace integrate_1d_new_test {
9+
namespace integrate_1d_impl_test {
1010

1111
std::ostringstream *msgs = nullptr;
1212

@@ -235,16 +235,16 @@ double order(double down, double up, const std::vector<double> &theta,
235235

236236
double v;
237237

238-
v = stan::math::integrate_1d_new(rank_density_functor__(),
238+
v = stan::math::integrate_1d_impl(rank_density_functor__(),
239239
down, up,
240240
1e-8, pstream__,
241241
theta, x_r, x_i);
242242
return v;
243243
}
244-
} // namespace integrate_1d_new_test
244+
} // namespace integrate_1d_impl_test
245245
/*
246246
* test_integration is a helper function to make it easy to test the
247-
* integrate_1d_new function.
247+
* integrate_1d_impl function.
248248
*
249249
* It takes in a callable function object, integration limits, parameters, real
250250
* and integer data. It integrates the provided function and compares the
@@ -271,13 +271,13 @@ double order(double down, double up, const std::vector<double> &theta,
271271
template <typename F, typename... Args>
272272
void test_integration(const F &f, double a, double b,
273273
double val, const Args&... args) {
274-
using stan::math::integrate_1d_new;
274+
using stan::math::integrate_1d_impl;
275275

276276
std::vector<double> tolerances = {1e-4, 1e-6, 1e-8};
277277

278278
for (auto tolerance : tolerances) {
279-
EXPECT_LE(std::abs(integrate_1d_new(f, a, b, tolerance,
280-
integrate_1d_new_test::msgs, args...)
279+
EXPECT_LE(std::abs(integrate_1d_impl(f, a, b, tolerance,
280+
integrate_1d_impl_test::msgs, args...)
281281
- val),
282282
tolerance);
283283
// Flip the domain of integration and check that the integral is working
@@ -287,151 +287,151 @@ void test_integration(const F &f, double a, double b,
287287
return f(-x, -xc, msgs, args...);
288288
};
289289

290-
EXPECT_LE(std::abs(integrate_1d_new(flipped, -b, -a, tolerance,
291-
integrate_1d_new_test::msgs, args...)
290+
EXPECT_LE(std::abs(integrate_1d_impl(flipped, -b, -a, tolerance,
291+
integrate_1d_impl_test::msgs, args...)
292292
- val),
293293
tolerance);
294294
}
295295
}
296296

297-
TEST(StanMath_integrate_1d_new_prim, TestThrows) {
297+
TEST(StanMath_integrate_1d_impl_prim, TestThrows) {
298298
// Left limit of integration must be less than or equal to right limit
299-
EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 1.0, 0.0,
300-
0.0, integrate_1d_new_test::msgs),
299+
EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 1.0, 0.0,
300+
0.0, integrate_1d_impl_test::msgs),
301301
std::domain_error);
302302
// NaN limits not okay
303303
EXPECT_THROW(
304-
stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0.0,
304+
stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0.0,
305305
std::numeric_limits<double>::quiet_NaN(),
306-
0.0, integrate_1d_new_test::msgs),
306+
0.0, integrate_1d_impl_test::msgs),
307307
std::domain_error);
308308
EXPECT_THROW(
309-
stan::math::integrate_1d_new(
310-
integrate_1d_new_test::f2{},
309+
stan::math::integrate_1d_impl(
310+
integrate_1d_impl_test::f2{},
311311
std::numeric_limits<double>::quiet_NaN(),
312-
0.0, 0.0, integrate_1d_new_test::msgs),
312+
0.0, 0.0, integrate_1d_impl_test::msgs),
313313
std::domain_error);
314314
EXPECT_THROW(
315-
stan::math::integrate_1d_new(
316-
integrate_1d_new_test::f2{}, std::numeric_limits<double>::quiet_NaN(),
315+
stan::math::integrate_1d_impl(
316+
integrate_1d_impl_test::f2{}, std::numeric_limits<double>::quiet_NaN(),
317317
std::numeric_limits<double>::quiet_NaN(), 0.0,
318-
integrate_1d_new_test::msgs),
318+
integrate_1d_impl_test::msgs),
319319
std::domain_error);
320320
// Two of the same inf limits not okay
321321
EXPECT_THROW(
322-
stan::math::integrate_1d_new(
323-
integrate_1d_new_test::f2{}, -std::numeric_limits<double>::infinity(),
322+
stan::math::integrate_1d_impl(
323+
integrate_1d_impl_test::f2{}, -std::numeric_limits<double>::infinity(),
324324
-std::numeric_limits<double>::infinity(), 0.0,
325-
integrate_1d_new_test::msgs),
325+
integrate_1d_impl_test::msgs),
326326
std::domain_error);
327327

328-
EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f2{},
328+
EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{},
329329
std::numeric_limits<double>::infinity(),
330330
std::numeric_limits<double>::infinity(),
331-
0.0, integrate_1d_new_test::msgs),
331+
0.0, integrate_1d_impl_test::msgs),
332332
std::domain_error);
333333
// xc should be nan if there are infinite limits
334-
EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{}, 0.0,
334+
EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{}, 0.0,
335335
std::numeric_limits<double>::infinity(),
336-
0.0, integrate_1d_new_test::msgs),
336+
0.0, integrate_1d_impl_test::msgs),
337337
std::runtime_error);
338-
EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{},
338+
EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{},
339339
std::numeric_limits<double>::infinity(),
340-
0.0, 0.0, integrate_1d_new_test::msgs),
340+
0.0, 0.0, integrate_1d_impl_test::msgs),
341341
std::domain_error);
342-
EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{},
342+
EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{},
343343
std::numeric_limits<double>::infinity(),
344344
std::numeric_limits<double>::infinity(),
345-
0.0, integrate_1d_new_test::msgs),
345+
0.0, integrate_1d_impl_test::msgs),
346346
std::domain_error);
347347
// But not otherwise
348-
EXPECT_NO_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{}, 0.0, 1.0,
349-
0.0, integrate_1d_new_test::msgs));
348+
EXPECT_NO_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{}, 0.0, 1.0,
349+
0.0, integrate_1d_impl_test::msgs));
350350
}
351351

352-
TEST(StanMath_integrate_1d_new_prim, test_integer_arguments) {
352+
TEST(StanMath_integrate_1d_impl_prim, test_integer_arguments) {
353353
double v;
354-
EXPECT_NO_THROW(v = stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0, 1,
355-
0.0, integrate_1d_new_test::msgs));
356-
EXPECT_NO_THROW(v = stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0.0, 1,
357-
0.0, integrate_1d_new_test::msgs));
358-
EXPECT_NO_THROW(v = stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0, 1.0,
359-
0.0, integrate_1d_new_test::msgs));
354+
EXPECT_NO_THROW(v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0, 1,
355+
0.0, integrate_1d_impl_test::msgs));
356+
EXPECT_NO_THROW(v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0.0, 1,
357+
0.0, integrate_1d_impl_test::msgs));
358+
EXPECT_NO_THROW(v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0, 1.0,
359+
0.0, integrate_1d_impl_test::msgs));
360360
}
361361

362-
TEST(StanMath_integrate_1d_new_prim, test1) {
362+
TEST(StanMath_integrate_1d_impl_prim, test1) {
363363
// Tricky integral from Boost docs + limit at infinity
364-
test_integration(integrate_1d_new_test::f1{}, 0.0,
364+
test_integration(integrate_1d_impl_test::f1{}, 0.0,
365365
std::numeric_limits<double>::infinity(),
366366
1.772453850905516);
367367
// Tricky integral from Boost 1d integration docs
368-
test_integration(integrate_1d_new_test::f2{}, 0.0, 1.0, 1.198140234735592);
368+
test_integration(integrate_1d_impl_test::f2{}, 0.0, 1.0, 1.198140234735592);
369369
// Tricky integral from Boost 1d integration docs
370-
test_integration(integrate_1d_new_test::f2{}, 0, 1, 1.198140234735592);
370+
test_integration(integrate_1d_impl_test::f2{}, 0, 1, 1.198140234735592);
371371
// Zero crossing integral + limit at infinity
372-
test_integration(integrate_1d_new_test::f3{}, -2.0,
372+
test_integration(integrate_1d_impl_test::f3{}, -2.0,
373373
std::numeric_limits<double>::infinity(), 7.38905609893065);
374374
// Easy integrals
375-
test_integration(integrate_1d_new_test::f4{}, 0.2, 0.7,
375+
test_integration(integrate_1d_impl_test::f4{}, 0.2, 0.7,
376376
1.0423499493102901, std::vector<double>({0.5}));
377-
test_integration(integrate_1d_new_test::f5{}, -0.2, 0.7,
377+
test_integration(integrate_1d_impl_test::f5{}, -0.2, 0.7,
378378
1.396621954392482, std::vector<double>({0.4, 0.4}));
379-
test_integration(integrate_1d_new_test::f4{}, 0.0, 0.0, 0.0,
379+
test_integration(integrate_1d_impl_test::f4{}, 0.0, 0.0, 0.0,
380380
std::vector<double>({0.5}));
381-
test_integration(integrate_1d_new_test::f5{}, 1.0, 1.0, 0.0,
381+
test_integration(integrate_1d_impl_test::f5{}, 1.0, 1.0, 0.0,
382382
std::vector<double>({0.4, 0.4}));
383383
// Test x_i
384-
test_integration(integrate_1d_new_test::f6{}, -0.2, 2.9,
384+
test_integration(integrate_1d_impl_test::f6{}, -0.2, 2.9,
385385
4131.985414616364, std::vector<double>({6.0, 5.1}),
386386
std::vector<int>({4}));
387387
// Test x_r
388-
test_integration(integrate_1d_new_test::f7{}, -0.2, 2.9,
388+
test_integration(integrate_1d_impl_test::f7{}, -0.2, 2.9,
389389
24219.985414616367,
390390
std::vector<double>({4.0, 6.0, 5.1}));
391391
// Both limits at infinity + test x_r/x_i
392-
test_integration(integrate_1d_new_test::f8{},
392+
test_integration(integrate_1d_impl_test::f8{},
393393
-std::numeric_limits<double>::infinity(),
394394
std::numeric_limits<double>::infinity(),
395395
3.013171546539377,
396396
std::vector<double>({5.0}),
397397
std::vector<double>({1.7}),
398398
std::vector<int>({2}));
399399
// Both limits at infinity + test x_i
400-
test_integration(integrate_1d_new_test::f9{},
400+
test_integration(integrate_1d_impl_test::f9{},
401401
-std::numeric_limits<double>::infinity(),
402402
std::numeric_limits<double>::infinity(),
403403
2.372032924895055,
404404
std::vector<double>({1.3}),
405405
std::vector<int>({4}));
406406
// Various integrals of beta function
407-
test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0,
407+
test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0,
408408
19.71463948905016, std::vector<double>({0.1, 0.1}));
409-
test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0,
409+
test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0,
410410
11.32308697521577, std::vector<double>({0.1, 0.5}));
411-
test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0,
411+
test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0,
412412
11.32308697521577, std::vector<double>({0.5, 0.1}));
413-
test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0,
413+
test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0,
414414
0.00952380952380952, std::vector<double>({5.0, 3.0}));
415415

416416
// Integrals from
417417
// http://crd-legacy.lbl.gov/~dhbailey/dhbpapers/dhb-tanh-sinh.pdf
418-
test_integration(integrate_1d_new_test::f12{}, 0.0,
418+
test_integration(integrate_1d_impl_test::f12{}, 0.0,
419419
std::numeric_limits<double>::infinity(), 2.0);
420-
test_integration(integrate_1d_new_test::f13{}, 0.0,
420+
test_integration(integrate_1d_impl_test::f13{}, 0.0,
421421
std::numeric_limits<double>::infinity(), 1.0);
422-
test_integration(integrate_1d_new_test::f14{}, 0.0, 1.0,
422+
test_integration(integrate_1d_impl_test::f14{}, 0.0, 1.0,
423423
exp(1) * sqrt(stan::math::pi()) * stan::math::erf(1.0));
424424

425425
// Integrals from http://crd-legacy.lbl.gov/~dhbailey/dhbpapers/quadrature.pdf
426426
// works normally but not to tolerance when limits of integration are flipped
427427
// test_integration(f15{}, 0.0, 1.0, {}, {}, {},
428428
// stan::math::square(stan::math::pi()) * (2 - sqrt(2.0)) /
429429
// 32);
430-
test_integration(integrate_1d_new_test::f16{}, 0.0, stan::math::pi(),
430+
test_integration(integrate_1d_impl_test::f16{}, 0.0, stan::math::pi(),
431431
stan::math::square(stan::math::pi()) / 4);
432432
}
433433

434-
TEST(StanMath_integrate_1d_new_prim, TestTolerance) {
434+
TEST(StanMath_integrate_1d_impl_prim, TestTolerance) {
435435
std::ostringstream *msgs = nullptr;
436436

437437
double t = 0.5;
@@ -444,5 +444,5 @@ TEST(StanMath_integrate_1d_new_prim, TestTolerance) {
444444
std::vector<double> theta = {t, A, v1, v2, s};
445445
std::vector<double> x_r;
446446

447-
EXPECT_NO_THROW(integrate_1d_new_test::order(-10, 0.67, theta, x_r, msgs));
447+
EXPECT_NO_THROW(integrate_1d_impl_test::order(-10, 0.67, theta, x_r, msgs));
448448
}

test/unit/math/rev/functor/integrate_1d_new_test.cpp renamed to test/unit/math/rev/functor/integrate_1d_impl_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void test_derivatives(const F &f, double a, double b,
216216
for (size_t i = 0; i < thetas.size(); ++i)
217217
thetas_[i] = thetas[i];
218218

219-
var integral = stan::math::integrate_1d_new(f, a_, b_, tolerance, msgs, thetas_, x_r, x_i);
219+
var integral = stan::math::integrate_1d_impl(f, a_, b_, tolerance, msgs, thetas_, x_r, x_i);
220220
integral.grad();
221221
EXPECT_LE(std::abs(val - integral.val()), tolerance);
222222
if (stan::is_var<T_theta>::value) {
@@ -239,11 +239,11 @@ TEST(StanMath_integrate_1d_rev, test_integer_arguments) {
239239
std::vector<double> x_r;
240240
std::vector<int> x_i;
241241
EXPECT_NO_THROW(
242-
v = stan::math::integrate_1d_new(f2{}, 0, 1, 1e-6, msgs, theta, x_r, x_i));
242+
v = stan::math::integrate_1d_impl(f2{}, 0, 1, 1e-6, msgs, theta, x_r, x_i));
243243
EXPECT_NO_THROW(
244-
v = stan::math::integrate_1d_new(f2{}, 0.0, 1, 1e-6, msgs, theta, x_r, x_i));
244+
v = stan::math::integrate_1d_impl(f2{}, 0.0, 1, 1e-6, msgs, theta, x_r, x_i));
245245
EXPECT_NO_THROW(
246-
v = stan::math::integrate_1d_new(f2{}, 0, 1.0, 1e-6, msgs, theta, x_r, x_i));
246+
v = stan::math::integrate_1d_impl(f2{}, 0, 1.0, 1e-6, msgs, theta, x_r, x_i));
247247
}
248248

249249
TEST(StanMath_integrate_1d_rev, TestDerivatives_easy) {

0 commit comments

Comments
 (0)