From 8f4397e110783f187829dbad3eacaa26d950e568 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Mon, 13 Apr 2026 13:52:55 +0200 Subject: [PATCH 1/9] Run CI tests on all operating systems --- .github/workflows/pytest.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 96d3f72..0f9af05 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -17,8 +17,9 @@ jobs: tests: strategy: matrix: + os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10", "3.14"] - runs-on: "ubuntu-latest" + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} From e3d55de348982229133acff325bed172b2137d87 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Mon, 13 Apr 2026 13:58:25 +0200 Subject: [PATCH 2/9] Relax rtol in poisson unit test --- tests/test_tinydft.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tinydft.py b/tests/test_tinydft.py index 93be5e3..5d9c1be 100644 --- a/tests/test_tinydft.py +++ b/tests/test_tinydft.py @@ -31,7 +31,7 @@ def test_poisson(atnum): vnum = solve_poisson(grid, rho) vann = (1 - aux) / grid.points - alpha * aux / 2 assert_allclose(vnum[-1], 1.0 / grid.points[-1], atol=1e-11, rtol=0) - assert_allclose(vnum, vann, rtol=1e-6, atol=0) + assert_allclose(vnum, vann, rtol=1e-5, atol=0) def test_interpret_econf1(): From 94e5f2effcfff65e2dee6bdebc8f21937a5f9027 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Tue, 14 Apr 2026 08:50:10 +0200 Subject: [PATCH 3/9] Show NumPy and SciPy configurations in GitHub Action --- .github/workflows/pytest.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 0f9af05..90622ad 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -29,6 +29,12 @@ jobs: - name: Install oldest versions of supported dependencies if: ${{ matrix.python-version == '3.10'}} run: pip install -r .github/requirements-old.txt + - name: Show NumPy and SciPy configurations + run: | + echo "================ NumPy configuration ================" + python -c "import numpy; numpy.show_config()" + echo "================ SciPy configuration ================" + python -c "import scipy; scipy.show_config()" - name: Install development version run: pip install -e .[dev] - name: Run pytest From 9dca3cd59ea862f0f48631da8144c67c68d86b09 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Tue, 14 Apr 2026 08:54:34 +0200 Subject: [PATCH 4/9] Include dev requirements in hackable setup instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0002c15..87bb5fa 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The details of setting up such an environment depend on your operating system an 1. Install the `tinydft` package from source in development mode: ```bash - pip install -e . + pip install -e .[dev] ``` ### User setup From 6dfc837963a6050c64e53ada065db06bfc0e181a Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Tue, 14 Apr 2026 09:08:56 +0200 Subject: [PATCH 5/9] Fix order of steps in GH Action --- .github/workflows/pytest.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 90622ad..3cc10d5 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -29,13 +29,13 @@ jobs: - name: Install oldest versions of supported dependencies if: ${{ matrix.python-version == '3.10'}} run: pip install -r .github/requirements-old.txt + - name: Install development version + run: pip install -e .[dev] - name: Show NumPy and SciPy configurations run: | echo "================ NumPy configuration ================" python -c "import numpy; numpy.show_config()" echo "================ SciPy configuration ================" python -c "import scipy; scipy.show_config()" - - name: Install development version - run: pip install -e .[dev] - name: Run pytest run: pytest -vv From 2ed7fabedfdc2b825e7f368f332bb131496584e6 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Wed, 15 Apr 2026 08:05:59 +0200 Subject: [PATCH 6/9] Relax thresholds with cpuinfo comments --- .github/workflows/pytest.yaml | 9 ++++++--- pyproject.toml | 1 + tests/test_tinybasis.py | 3 ++- tests/test_tinydft.py | 3 ++- tests/test_tinygrid.py | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 3cc10d5..af5ffe9 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -31,11 +31,14 @@ jobs: run: pip install -r .github/requirements-old.txt - name: Install development version run: pip install -e .[dev] - - name: Show NumPy and SciPy configurations + - name: Show CPU info + run: + cpuinfo + - name: Show NumPy configurations run: | - echo "================ NumPy configuration ================" python -c "import numpy; numpy.show_config()" - echo "================ SciPy configuration ================" + - name: Show SciPy configurations + run: | python -c "import scipy; scipy.show_config()" - name: Run pytest run: pytest -vv diff --git a/pyproject.toml b/pyproject.toml index a43001a..a53c8b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ dynamic = ["version"] [project.optional-dependencies] dev = [ + "py-cpuinfo", "pytest", "pytest-cov", "pytest-xdist", diff --git a/tests/test_tinybasis.py b/tests/test_tinybasis.py index b73f116..9d602a2 100644 --- a/tests/test_tinybasis.py +++ b/tests/test_tinybasis.py @@ -35,7 +35,8 @@ def test_hydrogenic_op(atnum, angqn, grid_basis): assert_allclose(norm, 1, atol=0, rtol=1e-8, err_msg=case) assert_allclose(eext, -factor, atol=0, rtol=1e-5, err_msg=case) assert_allclose(ekin, factor / 2, atol=0, rtol=1e-5, err_msg=case) - assert_allclose(evals[i], -factor / 2, atol=0, rtol=3e-6, err_msg=case) + # rtol increased from 3e-6 to 4e-6 for AMD Ryzen 5 5600H with Radeon Graphics + assert_allclose(evals[i], -factor / 2, atol=0, rtol=4e-6, err_msg=case) def test_integral_regression(num_regression): diff --git a/tests/test_tinydft.py b/tests/test_tinydft.py index 5d9c1be..968ddb5 100644 --- a/tests/test_tinydft.py +++ b/tests/test_tinydft.py @@ -31,7 +31,8 @@ def test_poisson(atnum): vnum = solve_poisson(grid, rho) vann = (1 - aux) / grid.points - alpha * aux / 2 assert_allclose(vnum[-1], 1.0 / grid.points[-1], atol=1e-11, rtol=0) - assert_allclose(vnum, vann, rtol=1e-5, atol=0) + # rtol increased from 1e-6 to 5e-6 for macOS runners on GitHub Actions + assert_allclose(vnum, vann, rtol=5e-5, atol=0) def test_interpret_econf1(): diff --git a/tests/test_tinygrid.py b/tests/test_tinygrid.py index f2dbcd5..4937483 100644 --- a/tests/test_tinygrid.py +++ b/tests/test_tinygrid.py @@ -113,7 +113,8 @@ def transform(x, np): fnvalsd = grid.derivative(fnvals) assert_allclose(grid.integrate(fnvals), 1.0, atol=1e-13, rtol=0) assert_allclose(fnvalsa, -fnvals, atol=1e-7, rtol=0) - assert_allclose(fnvalsd, -fnvals, atol=1e-7, rtol=0) + # atol reduced from 1e-7 to 2e-7 for Intel(R) Xeon(R) Gold 6240 CPU @ 2.60GHz + assert_allclose(fnvalsd, -fnvals, atol=2e-7, rtol=0) def test_tf_grid_exp_vectorized(): From 467f393a7706b086d4810a758df955b4c43568fb Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Wed, 15 Apr 2026 08:07:34 +0200 Subject: [PATCH 7/9] Add CPU of Apple runner --- tests/test_tinydft.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tinydft.py b/tests/test_tinydft.py index 968ddb5..4a292a4 100644 --- a/tests/test_tinydft.py +++ b/tests/test_tinydft.py @@ -31,7 +31,7 @@ def test_poisson(atnum): vnum = solve_poisson(grid, rho) vann = (1 - aux) / grid.points - alpha * aux / 2 assert_allclose(vnum[-1], 1.0 / grid.points[-1], atol=1e-11, rtol=0) - # rtol increased from 1e-6 to 5e-6 for macOS runners on GitHub Actions + # rtol increased from 1e-6 to 5e-6 for macOS runners on GitHub Actions, Apple M1 (Virtual) assert_allclose(vnum, vann, rtol=5e-5, atol=0) From 51713f778f9aa4ccbd8a19473e8c4578423cdd43 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Wed, 15 Apr 2026 08:10:31 +0200 Subject: [PATCH 8/9] Add comment in README on CPU sensitivity of unit tests --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 87bb5fa..614b902 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,11 @@ pytest See [the QC-Devs Contributor Guide](https://github.com/theochem/.github/blob/main/CONTRIBUTING.md) for more details. +A known issue is that some unit tests may fail on specific hardware, +with numerical errors slightly exceeding the specified tolerances. +When this happens, you can open an issue with the details of the failing test +and the output of the `cpuinfo` and `python -c "import numpy; numpy.show_config()"` commands. + ## Programming assignments In order of increasing difficulty: From 3a09f4627ad4dca3dee0d2f3ed323fc3acc9a901 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Wed, 15 Apr 2026 08:15:52 +0200 Subject: [PATCH 9/9] Add venv to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f136339..c290b48 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ build .envrc dist tmp +venv