From 5019637932eeebde5f92754f2d11d2c5c90d559e Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 24 Feb 2021 15:36:10 -0500 Subject: [PATCH] Renamed tests (Issue #2197) --- ...ew_test.cpp => integrate_1d_impl_test.cpp} | 126 +++++++++--------- ...ew_test.cpp => integrate_1d_impl_test.cpp} | 8 +- 2 files changed, 67 insertions(+), 67 deletions(-) rename test/unit/math/prim/functor/{integrate_1d_new_test.cpp => integrate_1d_impl_test.cpp} (76%) rename test/unit/math/rev/functor/{integrate_1d_new_test.cpp => integrate_1d_impl_test.cpp} (98%) diff --git a/test/unit/math/prim/functor/integrate_1d_new_test.cpp b/test/unit/math/prim/functor/integrate_1d_impl_test.cpp similarity index 76% rename from test/unit/math/prim/functor/integrate_1d_new_test.cpp rename to test/unit/math/prim/functor/integrate_1d_impl_test.cpp index 7daadabbb68..9f20b385744 100644 --- a/test/unit/math/prim/functor/integrate_1d_new_test.cpp +++ b/test/unit/math/prim/functor/integrate_1d_impl_test.cpp @@ -6,7 +6,7 @@ #include #include -namespace integrate_1d_new_test { +namespace integrate_1d_impl_test { std::ostringstream *msgs = nullptr; @@ -235,16 +235,16 @@ double order(double down, double up, const std::vector &theta, double v; - v = stan::math::integrate_1d_new(rank_density_functor__(), + v = stan::math::integrate_1d_impl(rank_density_functor__(), down, up, 1e-8, pstream__, theta, x_r, x_i); return v; } -} // namespace integrate_1d_new_test +} // namespace integrate_1d_impl_test /* * test_integration is a helper function to make it easy to test the - * integrate_1d_new function. + * integrate_1d_impl function. * * It takes in a callable function object, integration limits, parameters, real * and integer data. It integrates the provided function and compares the @@ -271,13 +271,13 @@ double order(double down, double up, const std::vector &theta, template void test_integration(const F &f, double a, double b, double val, const Args&... args) { - using stan::math::integrate_1d_new; + using stan::math::integrate_1d_impl; std::vector tolerances = {1e-4, 1e-6, 1e-8}; for (auto tolerance : tolerances) { - EXPECT_LE(std::abs(integrate_1d_new(f, a, b, tolerance, - integrate_1d_new_test::msgs, args...) + EXPECT_LE(std::abs(integrate_1d_impl(f, a, b, tolerance, + integrate_1d_impl_test::msgs, args...) - val), tolerance); // Flip the domain of integration and check that the integral is working @@ -287,109 +287,109 @@ void test_integration(const F &f, double a, double b, return f(-x, -xc, msgs, args...); }; - EXPECT_LE(std::abs(integrate_1d_new(flipped, -b, -a, tolerance, - integrate_1d_new_test::msgs, args...) + EXPECT_LE(std::abs(integrate_1d_impl(flipped, -b, -a, tolerance, + integrate_1d_impl_test::msgs, args...) - val), tolerance); } } -TEST(StanMath_integrate_1d_new_prim, TestThrows) { +TEST(StanMath_integrate_1d_impl_prim, TestThrows) { // Left limit of integration must be less than or equal to right limit - EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 1.0, 0.0, - 0.0, integrate_1d_new_test::msgs), + EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 1.0, 0.0, + 0.0, integrate_1d_impl_test::msgs), std::domain_error); // NaN limits not okay EXPECT_THROW( - stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0.0, + stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0.0, std::numeric_limits::quiet_NaN(), - 0.0, integrate_1d_new_test::msgs), + 0.0, integrate_1d_impl_test::msgs), std::domain_error); EXPECT_THROW( - stan::math::integrate_1d_new( - integrate_1d_new_test::f2{}, + stan::math::integrate_1d_impl( + integrate_1d_impl_test::f2{}, std::numeric_limits::quiet_NaN(), - 0.0, 0.0, integrate_1d_new_test::msgs), + 0.0, 0.0, integrate_1d_impl_test::msgs), std::domain_error); EXPECT_THROW( - stan::math::integrate_1d_new( - integrate_1d_new_test::f2{}, std::numeric_limits::quiet_NaN(), + stan::math::integrate_1d_impl( + integrate_1d_impl_test::f2{}, std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), 0.0, - integrate_1d_new_test::msgs), + integrate_1d_impl_test::msgs), std::domain_error); // Two of the same inf limits not okay EXPECT_THROW( - stan::math::integrate_1d_new( - integrate_1d_new_test::f2{}, -std::numeric_limits::infinity(), + stan::math::integrate_1d_impl( + integrate_1d_impl_test::f2{}, -std::numeric_limits::infinity(), -std::numeric_limits::infinity(), 0.0, - integrate_1d_new_test::msgs), + integrate_1d_impl_test::msgs), std::domain_error); - EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, + EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, std::numeric_limits::infinity(), std::numeric_limits::infinity(), - 0.0, integrate_1d_new_test::msgs), + 0.0, integrate_1d_impl_test::msgs), std::domain_error); // xc should be nan if there are infinite limits - EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{}, 0.0, + EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{}, 0.0, std::numeric_limits::infinity(), - 0.0, integrate_1d_new_test::msgs), + 0.0, integrate_1d_impl_test::msgs), std::runtime_error); - EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{}, + EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{}, std::numeric_limits::infinity(), - 0.0, 0.0, integrate_1d_new_test::msgs), + 0.0, 0.0, integrate_1d_impl_test::msgs), std::domain_error); - EXPECT_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{}, + EXPECT_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{}, std::numeric_limits::infinity(), std::numeric_limits::infinity(), - 0.0, integrate_1d_new_test::msgs), + 0.0, integrate_1d_impl_test::msgs), std::domain_error); // But not otherwise - EXPECT_NO_THROW(stan::math::integrate_1d_new(integrate_1d_new_test::f11{}, 0.0, 1.0, - 0.0, integrate_1d_new_test::msgs)); + EXPECT_NO_THROW(stan::math::integrate_1d_impl(integrate_1d_impl_test::f11{}, 0.0, 1.0, + 0.0, integrate_1d_impl_test::msgs)); } -TEST(StanMath_integrate_1d_new_prim, test_integer_arguments) { +TEST(StanMath_integrate_1d_impl_prim, test_integer_arguments) { double v; - EXPECT_NO_THROW(v = stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0, 1, - 0.0, integrate_1d_new_test::msgs)); - EXPECT_NO_THROW(v = stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0.0, 1, - 0.0, integrate_1d_new_test::msgs)); - EXPECT_NO_THROW(v = stan::math::integrate_1d_new(integrate_1d_new_test::f2{}, 0, 1.0, - 0.0, integrate_1d_new_test::msgs)); + EXPECT_NO_THROW(v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0, 1, + 0.0, integrate_1d_impl_test::msgs)); + EXPECT_NO_THROW(v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0.0, 1, + 0.0, integrate_1d_impl_test::msgs)); + EXPECT_NO_THROW(v = stan::math::integrate_1d_impl(integrate_1d_impl_test::f2{}, 0, 1.0, + 0.0, integrate_1d_impl_test::msgs)); } -TEST(StanMath_integrate_1d_new_prim, test1) { +TEST(StanMath_integrate_1d_impl_prim, test1) { // Tricky integral from Boost docs + limit at infinity - test_integration(integrate_1d_new_test::f1{}, 0.0, + test_integration(integrate_1d_impl_test::f1{}, 0.0, std::numeric_limits::infinity(), 1.772453850905516); // Tricky integral from Boost 1d integration docs - test_integration(integrate_1d_new_test::f2{}, 0.0, 1.0, 1.198140234735592); + test_integration(integrate_1d_impl_test::f2{}, 0.0, 1.0, 1.198140234735592); // Tricky integral from Boost 1d integration docs - test_integration(integrate_1d_new_test::f2{}, 0, 1, 1.198140234735592); + test_integration(integrate_1d_impl_test::f2{}, 0, 1, 1.198140234735592); // Zero crossing integral + limit at infinity - test_integration(integrate_1d_new_test::f3{}, -2.0, + test_integration(integrate_1d_impl_test::f3{}, -2.0, std::numeric_limits::infinity(), 7.38905609893065); // Easy integrals - test_integration(integrate_1d_new_test::f4{}, 0.2, 0.7, + test_integration(integrate_1d_impl_test::f4{}, 0.2, 0.7, 1.0423499493102901, std::vector({0.5})); - test_integration(integrate_1d_new_test::f5{}, -0.2, 0.7, + test_integration(integrate_1d_impl_test::f5{}, -0.2, 0.7, 1.396621954392482, std::vector({0.4, 0.4})); - test_integration(integrate_1d_new_test::f4{}, 0.0, 0.0, 0.0, + test_integration(integrate_1d_impl_test::f4{}, 0.0, 0.0, 0.0, std::vector({0.5})); - test_integration(integrate_1d_new_test::f5{}, 1.0, 1.0, 0.0, + test_integration(integrate_1d_impl_test::f5{}, 1.0, 1.0, 0.0, std::vector({0.4, 0.4})); // Test x_i - test_integration(integrate_1d_new_test::f6{}, -0.2, 2.9, + test_integration(integrate_1d_impl_test::f6{}, -0.2, 2.9, 4131.985414616364, std::vector({6.0, 5.1}), std::vector({4})); // Test x_r - test_integration(integrate_1d_new_test::f7{}, -0.2, 2.9, + test_integration(integrate_1d_impl_test::f7{}, -0.2, 2.9, 24219.985414616367, std::vector({4.0, 6.0, 5.1})); // Both limits at infinity + test x_r/x_i - test_integration(integrate_1d_new_test::f8{}, + test_integration(integrate_1d_impl_test::f8{}, -std::numeric_limits::infinity(), std::numeric_limits::infinity(), 3.013171546539377, @@ -397,29 +397,29 @@ TEST(StanMath_integrate_1d_new_prim, test1) { std::vector({1.7}), std::vector({2})); // Both limits at infinity + test x_i - test_integration(integrate_1d_new_test::f9{}, + test_integration(integrate_1d_impl_test::f9{}, -std::numeric_limits::infinity(), std::numeric_limits::infinity(), 2.372032924895055, std::vector({1.3}), std::vector({4})); // Various integrals of beta function - test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0, + test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0, 19.71463948905016, std::vector({0.1, 0.1})); - test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0, + test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0, 11.32308697521577, std::vector({0.1, 0.5})); - test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0, + test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0, 11.32308697521577, std::vector({0.5, 0.1})); - test_integration(integrate_1d_new_test::f10{}, 0.0, 1.0, + test_integration(integrate_1d_impl_test::f10{}, 0.0, 1.0, 0.00952380952380952, std::vector({5.0, 3.0})); // Integrals from // http://crd-legacy.lbl.gov/~dhbailey/dhbpapers/dhb-tanh-sinh.pdf - test_integration(integrate_1d_new_test::f12{}, 0.0, + test_integration(integrate_1d_impl_test::f12{}, 0.0, std::numeric_limits::infinity(), 2.0); - test_integration(integrate_1d_new_test::f13{}, 0.0, + test_integration(integrate_1d_impl_test::f13{}, 0.0, std::numeric_limits::infinity(), 1.0); - test_integration(integrate_1d_new_test::f14{}, 0.0, 1.0, + test_integration(integrate_1d_impl_test::f14{}, 0.0, 1.0, exp(1) * sqrt(stan::math::pi()) * stan::math::erf(1.0)); // Integrals from http://crd-legacy.lbl.gov/~dhbailey/dhbpapers/quadrature.pdf @@ -427,11 +427,11 @@ TEST(StanMath_integrate_1d_new_prim, test1) { // test_integration(f15{}, 0.0, 1.0, {}, {}, {}, // stan::math::square(stan::math::pi()) * (2 - sqrt(2.0)) / // 32); - test_integration(integrate_1d_new_test::f16{}, 0.0, stan::math::pi(), + test_integration(integrate_1d_impl_test::f16{}, 0.0, stan::math::pi(), stan::math::square(stan::math::pi()) / 4); } -TEST(StanMath_integrate_1d_new_prim, TestTolerance) { +TEST(StanMath_integrate_1d_impl_prim, TestTolerance) { std::ostringstream *msgs = nullptr; double t = 0.5; @@ -444,5 +444,5 @@ TEST(StanMath_integrate_1d_new_prim, TestTolerance) { std::vector theta = {t, A, v1, v2, s}; std::vector x_r; - EXPECT_NO_THROW(integrate_1d_new_test::order(-10, 0.67, theta, x_r, msgs)); + EXPECT_NO_THROW(integrate_1d_impl_test::order(-10, 0.67, theta, x_r, msgs)); } diff --git a/test/unit/math/rev/functor/integrate_1d_new_test.cpp b/test/unit/math/rev/functor/integrate_1d_impl_test.cpp similarity index 98% rename from test/unit/math/rev/functor/integrate_1d_new_test.cpp rename to test/unit/math/rev/functor/integrate_1d_impl_test.cpp index 4f417fee777..2288b4baa01 100644 --- a/test/unit/math/rev/functor/integrate_1d_new_test.cpp +++ b/test/unit/math/rev/functor/integrate_1d_impl_test.cpp @@ -216,7 +216,7 @@ void test_derivatives(const F &f, double a, double b, for (size_t i = 0; i < thetas.size(); ++i) thetas_[i] = thetas[i]; - var integral = stan::math::integrate_1d_new(f, a_, b_, tolerance, msgs, thetas_, x_r, x_i); + var integral = stan::math::integrate_1d_impl(f, a_, b_, tolerance, msgs, thetas_, x_r, x_i); integral.grad(); EXPECT_LE(std::abs(val - integral.val()), tolerance); if (stan::is_var::value) { @@ -239,11 +239,11 @@ TEST(StanMath_integrate_1d_rev, test_integer_arguments) { std::vector x_r; std::vector x_i; EXPECT_NO_THROW( - v = stan::math::integrate_1d_new(f2{}, 0, 1, 1e-6, msgs, theta, x_r, x_i)); + v = stan::math::integrate_1d_impl(f2{}, 0, 1, 1e-6, msgs, theta, x_r, x_i)); EXPECT_NO_THROW( - v = stan::math::integrate_1d_new(f2{}, 0.0, 1, 1e-6, msgs, theta, x_r, x_i)); + v = stan::math::integrate_1d_impl(f2{}, 0.0, 1, 1e-6, msgs, theta, x_r, x_i)); EXPECT_NO_THROW( - v = stan::math::integrate_1d_new(f2{}, 0, 1.0, 1e-6, msgs, theta, x_r, x_i)); + v = stan::math::integrate_1d_impl(f2{}, 0, 1.0, 1e-6, msgs, theta, x_r, x_i)); } TEST(StanMath_integrate_1d_rev, TestDerivatives_easy) {