Skip to content

Commit 02ed86b

Browse files
authored
Merge pull request #19 from lucascolley/macos
CI: test macOS
2 parents 99ad371 + 999623b commit 02ed86b

File tree

9 files changed

+523
-182
lines changed

9 files changed

+523
-182
lines changed

.github/workflows/linux.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Linux Tests
1+
name: Tests
22

33
on: [ push, pull_request ]
44

@@ -13,20 +13,23 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16-
gcc_x86_64_linux:
17-
name: GCC X86_64 Linux
18-
runs-on: ubuntu-22.04
16+
tests:
17+
name: ${{ matrix.environment }} ${{ matrix.runs-on }}
18+
runs-on: ${{ matrix.runs-on }}
1919
env:
2020
XSREF_TABLES_PATH: "${{ github.workspace }}/xsref/tables"
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
environment: [tests-ci]
25+
runs-on: [ubuntu-latest, macos-latest]
2126

2227
steps:
2328
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2429
- uses: prefix-dev/setup-pixi@92815284c57faa15cd896c4d5cfb2d59f32dc43d # v0.8.3
2530
with:
2631
pixi-version: v0.44.0
2732
cache: true
33+
environments: ${{ matrix.environment }}
2834
- name: Run tests
29-
run: |
30-
pixi run configure-tests
31-
pixi run build-only -j2
32-
pixi run tests -j2
35+
run: pixi run --environment=tests-ci tests-ci

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# xsf
2-
Special function implementations
2+
Special function implementations.
3+
4+
See https://github.com/scipy/xsf/issues/1 for context.
35

46
## Tests
57

@@ -9,16 +11,19 @@ To run the tests:
911
- [install Pixi](https://pixi.sh/latest/#installation)
1012
- `pixi run tests`
1113

12-
For subsequent test runs, you can skip re-cloning [`xsref`](https://github.com/scipy/xsref) with:
14+
You can trigger a rebuild inbetween test runs with:
1315

1416
```shell
15-
pixi run --skip-deps tests
17+
pixi run build-tests
1618
```
1719

18-
You can trigger a rebuild inbetween test runs with:
20+
For subsequent test runs, to skip re-cloning [`xsref`](https://github.com/scipy/xsref) or to control parallelism for individual commands, you can use:
1921

2022
```shell
21-
pixi run build-tests
23+
pixi run clone-xsf
24+
pixi run configure-tests
25+
pixi run build-only -j8
26+
pixi run --skip-deps tests -j2
2227
```
2328

2429
> [!NOTE]

pixi.lock

Lines changed: 464 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ depends-on = ["configure", "build-only"]
3838

3939
[feature.tests.dependencies]
4040
catch2 = ">=3.8.0,<4"
41-
ccache = ">=4.11.2,<5"
4241
libarrow-all = ">=19.0.1,<20"
4342

4443
[feature.tests.tasks]
@@ -63,10 +62,24 @@ configure-tests.env.XSREF_TABLES_PATH = "$PWD/xsref/tables"
6362
# build for tests
6463
build-tests.depends-on = ["configure-tests", "build-only"]
6564
# run tests
66-
tests.cmd = "ctest --output-on-failure --test-dir build/tests"
65+
tests.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests"]
6766
tests.depends-on = ["clone-xsref", "build-tests"]
6867
tests.cwd = "."
6968

69+
[feature.tests-ci.dependencies]
70+
ccache = ">=4.11.2,<5"
71+
72+
[feature.tests-ci.tasks]
73+
# TODO: use a task arg for parallelism https://github.com/prefix-dev/pixi/pull/3433
74+
build-tests-ci.cmd = ["cmake", "--build", "build", "-j3"]
75+
build-tests-ci.depends-on = ["clone-xsref", "configure-tests"]
76+
build-tests-ci.cwd = "."
77+
78+
# run tests
79+
tests-ci.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests", "-j3"]
80+
tests-ci.depends-on = ["build-tests-ci"]
81+
tests-ci.cwd = "."
82+
7083
## Coverage
7184

7285
# [feature.coverage.dependencies]
@@ -93,4 +106,5 @@ tests.cwd = "."
93106
# cmd = "ctest"
94107

95108
[environments]
96-
default = ["build", "tests"]
109+
default = { features = ["build", "tests"], solve-group = "default" }
110+
tests-ci = { features = ["build", "tests", "tests-ci"], solve-group = "default" }

tests/scipy_special_tests/test_bdtr.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,3 @@ TEST_CASE("bdtr dpd->d scipy_special_tests", "[bdtr][dpd->d][scipy_special_tests
2222
CAPTURE(k, n, p, out, desired, error, tol, fallback);
2323
REQUIRE(error <= tol);
2424
}
25-
26-
TEST_CASE("bdtr ddd->d scipy_special_tests", "[bdtr][ddd->d][scipy_special_tests]") {
27-
SET_FP_FORMAT()
28-
auto [input, output, tol] =
29-
GENERATE(xsf_test_cases<std::tuple<double, double, double>, std::tuple<double, bool>, double>(
30-
tables_path / "In_d_d_d-d.parquet", tables_path / "Out_d_d_d-d.parquet",
31-
tables_path / ("Err_d_d_d-d_" + get_platform_str() + ".parquet")
32-
));
33-
34-
auto [k, n, p] = input;
35-
auto [desired, fallback] = output;
36-
auto out = xsf::bdtr(k, n, p);
37-
auto error = xsf::extended_relative_error(out, desired);
38-
tol = adjust_tolerance(tol);
39-
CAPTURE(k, n, p, out, desired, error, tol, fallback);
40-
REQUIRE(error <= tol);
41-
}

tests/scipy_special_tests/test_bdtrc.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,3 @@ TEST_CASE("bdtrc dpd->d scipy_special_tests", "[bdtrc][dpd->d][scipy_special_tes
2222
CAPTURE(k, n, p, out, desired, error, tol, fallback);
2323
REQUIRE(error <= tol);
2424
}
25-
26-
TEST_CASE("bdtrc ddd->d scipy_special_tests", "[bdtrc][ddd->d][scipy_special_tests]") {
27-
SET_FP_FORMAT()
28-
auto [input, output, tol] =
29-
GENERATE(xsf_test_cases<std::tuple<double, double, double>, std::tuple<double, bool>, double>(
30-
tables_path / "In_d_d_d-d.parquet", tables_path / "Out_d_d_d-d.parquet",
31-
tables_path / ("Err_d_d_d-d_" + get_platform_str() + ".parquet")
32-
));
33-
34-
auto [k, n, p] = input;
35-
auto [desired, fallback] = output;
36-
auto out = xsf::bdtrc(k, n, p);
37-
auto error = xsf::extended_relative_error(out, desired);
38-
tol = adjust_tolerance(tol);
39-
CAPTURE(k, n, p, out, desired, error, tol, fallback);
40-
REQUIRE(error <= tol);
41-
}

tests/scipy_special_tests/test_bdtri.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,3 @@ TEST_CASE("bdtri dpd->d scipy_special_tests", "[bdtri][dpd->d][scipy_special_tes
2222
CAPTURE(k, n, y, out, desired, error, tol, fallback);
2323
REQUIRE(error <= tol);
2424
}
25-
26-
TEST_CASE("bdtri ddd->d scipy_special_tests", "[bdtri][ddd->d][scipy_special_tests]") {
27-
SET_FP_FORMAT()
28-
auto [input, output, tol] =
29-
GENERATE(xsf_test_cases<std::tuple<double, double, double>, std::tuple<double, bool>, double>(
30-
tables_path / "In_d_d_d-d.parquet", tables_path / "Out_d_d_d-d.parquet",
31-
tables_path / ("Err_d_d_d-d_" + get_platform_str() + ".parquet")
32-
));
33-
34-
auto [k, n, y] = input;
35-
auto [desired, fallback] = output;
36-
auto out = xsf::bdtri(k, n, y);
37-
auto error = xsf::extended_relative_error(out, desired);
38-
tol = adjust_tolerance(tol);
39-
CAPTURE(k, n, y, out, desired, error, tol, fallback);
40-
REQUIRE(error <= tol);
41-
}

tests/scipy_special_tests/test_cyl_bessel_i.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST_CASE("cyl_bessel_i dD->D scipy_special_tests", "[cyl_bessel_i][dD->D][scipy
3535
auto [desired, fallback] = output;
3636
auto out = xsf::cyl_bessel_i(v, z);
3737
auto error = xsf::extended_relative_error(out, desired);
38-
tol = adjust_tolerance(tol);
38+
tol = adjust_tolerance(tol, 12.0);
3939
CAPTURE(v, z, out, desired, error, tol, fallback);
4040
REQUIRE(error <= tol);
4141
}

tests/testing_utils.h

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class TableReader {
7070
V imag;
7171
*stream_ >> real >> imag;
7272
element = U(real, imag);
73+
} else if constexpr (std::is_same_v<U, std::ptrdiff_t>) {
74+
std::int64_t val;
75+
*stream_ >> val;
76+
element = static_cast<std::ptrdiff_t>(val);
7377
} else {
7478
*stream_ >> element;
7579
}
@@ -127,25 +131,30 @@ Catch::Generators::GeneratorWrapper<std::tuple<T1, T2, T3>> xsf_test_cases(
127131
);
128132
}
129133

130-
131134
template <typename T>
132-
T adjust_tolerance(T tol) {
135+
T adjust_tolerance(T tol, T factor = 4) {
133136
// Add some wiggle room to tolerance from table.
134-
return 4 * std::max(std::numeric_limits<T>::epsilon(), tol);
137+
return factor * std::max(std::numeric_limits<T>::epsilon(), tol);
135138
}
136139

137-
138140
std::string get_platform_str() {
139-
/* This is going to get a string "<compiler>-<os>-<architecture>" using conditional
140-
* compilation, but for now we're just stubbing things out. */
141+
/* This should use Boost.Predef
142+
* https://www.boost.org/doc/libs/1_87_0/libs/predef/doc/index.html
143+
* (Boost isn't a dependency yet but this is planned)
144+
* and we should have tolerance files for a wider variety of
145+
* compiler/os/architecture combos, including for specific compiler
146+
* versions. For now, there are these two platforms with tolerance
147+
* files and we use the former with Clang on Mac and the later
148+
* otherwise. */
149+
#if defined(__clang__) && defined(__APPLE__)
150+
return "clang-darwin-aarch64";
151+
#else
141152
return "gcc-linux-x86_64";
153+
#endif
142154
}
143155

144-
145-
146156
} // namespace
147157

148-
149-
#define SET_FP_FORMAT() \
150-
Catch::StringMaker<double>::precision = std::numeric_limits<double>::max_digits10; \
158+
#define SET_FP_FORMAT() \
159+
Catch::StringMaker<double>::precision = std::numeric_limits<double>::max_digits10; \
151160
Catch::StringMaker<float>::precision = std::numeric_limits<float>::max_digits10;

0 commit comments

Comments
 (0)