Skip to content

Commit 48d659f

Browse files
committed
TST: Add scipy_special_tests
1 parent e8447e5 commit 48d659f

File tree

174 files changed

+4552
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+4552
-2
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ find_package(Parquet REQUIRED)
1111
add_library(xsf INTERFACE)
1212
target_include_directories(xsf INTERFACE ${CMAKE_SOURCE_DIR}/include)
1313

14-
file(GLOB TEST_SOURCES "test_*.cpp")
14+
file(GLOB TEST_SOURCES "*/test_*.cpp")
1515
foreach(test_file ${TEST_SOURCES})
1616
get_filename_component(test_name ${test_file} NAME_WE)
1717
add_executable(${test_name}.test ${test_file})
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/airy.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "airy"};
8+
9+
TEST_CASE("airy D->DDDD scipy_special_tests", "[airy][D->DDDD][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] = GENERATE(
12+
xsf_test_cases<
13+
std::complex<double>,
14+
std::tuple<std::complex<double>, std::complex<double>, std::complex<double>, std::complex<double>, bool>,
15+
std::tuple<double, double, double, double>>(
16+
tables_path / "In_cd-cd_cd_cd_cd.parquet", tables_path / "Out_cd-cd_cd_cd_cd.parquet",
17+
tables_path / ("Err_cd-cd_cd_cd_cd_" + get_platform_str() + ".parquet")
18+
)
19+
);
20+
21+
auto z = input;
22+
auto [desired0, desired1, desired2, desired3, fallback] = output;
23+
24+
std::complex<double> out0;
25+
std::complex<double> out1;
26+
std::complex<double> out2;
27+
std::complex<double> out3;
28+
29+
xsf::airy(z, out0, out1, out2, out3);
30+
auto [tol0, tol1, tol2, tol3] = tol;
31+
32+
auto error0 = xsf::extended_relative_error(out0, desired0);
33+
tol0 = adjust_tolerance(tol0);
34+
CAPTURE(z, out0, desired0, error0, tol0, fallback);
35+
REQUIRE(error0 <= tol0);
36+
37+
auto error1 = xsf::extended_relative_error(out1, desired1);
38+
tol1 = adjust_tolerance(tol1);
39+
CAPTURE(z, out1, desired1, error1, tol1, fallback);
40+
REQUIRE(error1 <= tol1);
41+
42+
auto error2 = xsf::extended_relative_error(out2, desired2);
43+
tol2 = adjust_tolerance(tol2);
44+
CAPTURE(z, out2, desired2, error2, tol2, fallback);
45+
REQUIRE(error2 <= tol2);
46+
47+
auto error3 = xsf::extended_relative_error(out3, desired3);
48+
tol3 = adjust_tolerance(tol3);
49+
CAPTURE(z, out3, desired3, error3, tol3, fallback);
50+
REQUIRE(error3 <= tol3);
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/airy.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "airye"};
8+
9+
TEST_CASE("airye D->DDDD scipy_special_tests", "[airye][D->DDDD][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] = GENERATE(
12+
xsf_test_cases<
13+
std::complex<double>,
14+
std::tuple<std::complex<double>, std::complex<double>, std::complex<double>, std::complex<double>, bool>,
15+
std::tuple<double, double, double, double>>(
16+
tables_path / "In_cd-cd_cd_cd_cd.parquet", tables_path / "Out_cd-cd_cd_cd_cd.parquet",
17+
tables_path / ("Err_cd-cd_cd_cd_cd_" + get_platform_str() + ".parquet")
18+
)
19+
);
20+
21+
auto z = input;
22+
auto [desired0, desired1, desired2, desired3, fallback] = output;
23+
24+
std::complex<double> out0;
25+
std::complex<double> out1;
26+
std::complex<double> out2;
27+
std::complex<double> out3;
28+
29+
xsf::airye(z, out0, out1, out2, out3);
30+
auto [tol0, tol1, tol2, tol3] = tol;
31+
32+
auto error0 = xsf::extended_relative_error(out0, desired0);
33+
tol0 = adjust_tolerance(tol0);
34+
CAPTURE(z, out0, desired0, error0, tol0, fallback);
35+
REQUIRE(error0 <= tol0);
36+
37+
auto error1 = xsf::extended_relative_error(out1, desired1);
38+
tol1 = adjust_tolerance(tol1);
39+
CAPTURE(z, out1, desired1, error1, tol1, fallback);
40+
REQUIRE(error1 <= tol1);
41+
42+
auto error2 = xsf::extended_relative_error(out2, desired2);
43+
tol2 = adjust_tolerance(tol2);
44+
CAPTURE(z, out2, desired2, error2, tol2, fallback);
45+
REQUIRE(error2 <= tol2);
46+
47+
auto error3 = xsf::extended_relative_error(out3, desired3);
48+
tol3 = adjust_tolerance(tol3);
49+
CAPTURE(z, out3, desired3, error3, tol3, fallback);
50+
REQUIRE(error3 <= tol3);
51+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/stats.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "bdtr"};
8+
9+
TEST_CASE("bdtr dpd->d scipy_special_tests", "[bdtr][dpd->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] =
12+
GENERATE(xsf_test_cases<std::tuple<double, std::ptrdiff_t, double>, std::tuple<double, bool>, double>(
13+
tables_path / "In_d_p_d-d.parquet", tables_path / "Out_d_p_d-d.parquet",
14+
tables_path / ("Err_d_p_d-d_" + get_platform_str() + ".parquet")
15+
));
16+
17+
auto [k, n, p] = input;
18+
auto [desired, fallback] = output;
19+
auto out = xsf::bdtr(k, n, p);
20+
auto error = xsf::extended_relative_error(out, desired);
21+
tol = adjust_tolerance(tol);
22+
CAPTURE(k, n, p, out, desired, error, tol, fallback);
23+
REQUIRE(error <= tol);
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/stats.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "bdtrc"};
8+
9+
TEST_CASE("bdtrc dpd->d scipy_special_tests", "[bdtrc][dpd->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] =
12+
GENERATE(xsf_test_cases<std::tuple<double, std::ptrdiff_t, double>, std::tuple<double, bool>, double>(
13+
tables_path / "In_d_p_d-d.parquet", tables_path / "Out_d_p_d-d.parquet",
14+
tables_path / ("Err_d_p_d-d_" + get_platform_str() + ".parquet")
15+
));
16+
17+
auto [k, n, p] = input;
18+
auto [desired, fallback] = output;
19+
auto out = xsf::bdtrc(k, n, p);
20+
auto error = xsf::extended_relative_error(out, desired);
21+
tol = adjust_tolerance(tol);
22+
CAPTURE(k, n, p, out, desired, error, tol, fallback);
23+
REQUIRE(error <= tol);
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/stats.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "bdtri"};
8+
9+
TEST_CASE("bdtri dpd->d scipy_special_tests", "[bdtri][dpd->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] =
12+
GENERATE(xsf_test_cases<std::tuple<double, std::ptrdiff_t, double>, std::tuple<double, bool>, double>(
13+
tables_path / "In_d_p_d-d.parquet", tables_path / "Out_d_p_d-d.parquet",
14+
tables_path / ("Err_d_p_d-d_" + get_platform_str() + ".parquet")
15+
));
16+
17+
auto [k, n, y] = input;
18+
auto [desired, fallback] = output;
19+
auto out = xsf::bdtri(k, n, y);
20+
auto error = xsf::extended_relative_error(out, desired);
21+
tol = adjust_tolerance(tol);
22+
CAPTURE(k, n, y, out, desired, error, tol, fallback);
23+
REQUIRE(error <= tol);
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/kelvin.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "bei"};
8+
9+
TEST_CASE("bei d->d scipy_special_tests", "[bei][d->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] = GENERATE(xsf_test_cases<double, std::tuple<double, bool>, double>(
12+
tables_path / "In_d-d.parquet", tables_path / "Out_d-d.parquet",
13+
tables_path / ("Err_d-d_" + get_platform_str() + ".parquet")
14+
));
15+
16+
auto x = input;
17+
auto [desired, fallback] = output;
18+
auto out = xsf::bei(x);
19+
auto error = xsf::extended_relative_error(out, desired);
20+
tol = adjust_tolerance(tol);
21+
CAPTURE(x, out, desired, error, tol, fallback);
22+
REQUIRE(error <= tol);
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/kelvin.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "beip"};
8+
9+
TEST_CASE("beip d->d scipy_special_tests", "[beip][d->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] = GENERATE(xsf_test_cases<double, std::tuple<double, bool>, double>(
12+
tables_path / "In_d-d.parquet", tables_path / "Out_d-d.parquet",
13+
tables_path / ("Err_d-d_" + get_platform_str() + ".parquet")
14+
));
15+
16+
auto x = input;
17+
auto [desired, fallback] = output;
18+
auto out = xsf::beip(x);
19+
auto error = xsf::extended_relative_error(out, desired);
20+
tol = adjust_tolerance(tol);
21+
CAPTURE(x, out, desired, error, tol, fallback);
22+
REQUIRE(error <= tol);
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/kelvin.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "ber"};
8+
9+
TEST_CASE("ber d->d scipy_special_tests", "[ber][d->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] = GENERATE(xsf_test_cases<double, std::tuple<double, bool>, double>(
12+
tables_path / "In_d-d.parquet", tables_path / "Out_d-d.parquet",
13+
tables_path / ("Err_d-d_" + get_platform_str() + ".parquet")
14+
));
15+
16+
auto x = input;
17+
auto [desired, fallback] = output;
18+
auto out = xsf::ber(x);
19+
auto error = xsf::extended_relative_error(out, desired);
20+
tol = adjust_tolerance(tol);
21+
CAPTURE(x, out, desired, error, tol, fallback);
22+
REQUIRE(error <= tol);
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "../testing_utils.h"
2+
3+
#include <xsf/kelvin.h>
4+
5+
namespace fs = std::filesystem;
6+
7+
fs::path tables_path{fs::path(XSREF_TABLES_PATH) / "scipy_special_tests" / "berp"};
8+
9+
TEST_CASE("berp d->d scipy_special_tests", "[berp][d->d][scipy_special_tests]") {
10+
SET_FP_FORMAT()
11+
auto [input, output, tol] = GENERATE(xsf_test_cases<double, std::tuple<double, bool>, double>(
12+
tables_path / "In_d-d.parquet", tables_path / "Out_d-d.parquet",
13+
tables_path / ("Err_d-d_" + get_platform_str() + ".parquet")
14+
));
15+
16+
auto x = input;
17+
auto [desired, fallback] = output;
18+
auto out = xsf::berp(x);
19+
auto error = xsf::extended_relative_error(out, desired);
20+
tol = adjust_tolerance(tol);
21+
CAPTURE(x, out, desired, error, tol, fallback);
22+
REQUIRE(error <= tol);
23+
}

0 commit comments

Comments
 (0)