From 50303b2cb972d5aaec3fd9acde37bc26d30101c1 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 16:42:34 +0000 Subject: [PATCH 1/7] add coveralls testing --- .github/workflows/test.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0684d6a..ebbb465 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,6 +27,9 @@ jobs: env: NUMBA_DISABLE_COVERAGE: "1" run: | - coverage run -m pytest -v -s - + coverage run -m pytest -v -s + - name: Upload coverage to Coveralls + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From d6ac912e3523c7dc466ea9ba706002b59a30546c Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 16:50:57 +0000 Subject: [PATCH 2/7] increase coverage --- tests/test_flex.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/test_flex.py b/tests/test_flex.py index 4c9ee9d..219ea72 100644 --- a/tests/test_flex.py +++ b/tests/test_flex.py @@ -59,7 +59,15 @@ def test_flex_total_power(): mass = np.random.uniform(0, 1, 100) velocity = np.random.uniform(0, 100, 100) - F = flex.FLEX(rscl, mmax, nmax, R, phi, mass, velocity) + # test the slower, careful, newaxis version + F = flex.FLEX(rscl, mmax, nmax, R, phi, mass, velocity, newaxis=True) + + # test the faster vectorised version + G = flex.FLEX(rscl, mmax, nmax, R, phi, mass, velocity) + + # check that both methods give the same coefficients + np.testing.assert_allclose(F.coscoefs, G.coscoefs) + np.testing.assert_allclose(F.sincoefs, G.sincoefs) # Compute total power in each harmonic totalm = np.linalg.norm(np.sqrt(F.coscoefs**2 + F.sincoefs**2), axis=1) @@ -68,4 +76,21 @@ def test_flex_total_power(): assert totalm.shape[0] == mmax + 1 # Check that totalm values are non-negative - assert np.all(totalm >= 0) \ No newline at end of file + assert np.all(totalm >= 0) + + +def test_flex_total_normalisation(): + # Create a FLEX instance + rscl = 1.0 + mmax = 0 + nmax = 1 + R = np.linspace(0.1, 5.0, 100) + phi = np.linspace(0, 2*np.pi, 100) + mass = np.ones(100) + + F = flex.FLEX(rscl, mmax, nmax, R, phi, mass) + + F.laguerre_reconstruction(R,phi) + + # check the values for the norm + #print(F.reconstruction) From 5a50e24e4f9bd1998ab4e7f374dd9f53ed001754 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 17:13:32 +0000 Subject: [PATCH 3/7] test nonsense inputs --- tests/test_flex.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_flex.py b/tests/test_flex.py index 219ea72..5173b00 100644 --- a/tests/test_flex.py +++ b/tests/test_flex.py @@ -46,9 +46,32 @@ def test_flex_initialization(): with pytest.raises(ValueError): flex.FLEX(rscl, mmax, nmax, R, phi, mass, velocity[:-1]) + # Test nonsense inputs + with pytest.raises(ValueError): + flex.FLEX(rscl, mmax, nmax, True, phi, mass, velocity) + with pytest.raises(ValueError): + flex.FLEX(rscl, mmax, nmax, R, True, mass, velocity) + with pytest.raises(ValueError): + flex.FLEX(rscl, mmax, nmax, R, phi, True, velocity) + with pytest.raises(ValueError): + flex.FLEX(rscl, mmax, nmax, R, phi, mass, True) + def test_flex_version(): assert isinstance(flex.__version__, str) +def test_flex_scalars(): + # Create a FLEX instance + rscl = 1.0 + mmax = 2 + nmax = 10 + R = np.linspace(0.1, 5.0, 100) + phi = np.linspace(0, 2*np.pi, 100) + mass = 1.0 + velocity = 1.0 + + F = flex.FLEX(rscl, mmax, nmax, R, phi, mass, velocity) + + def test_flex_total_power(): # Create a FLEX instance rscl = 1.0 From b26ab2089e8dcd110051d2660a8afecd153c1481 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 17:19:40 +0000 Subject: [PATCH 4/7] fix nonsense test --- tests/test_flex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_flex.py b/tests/test_flex.py index 5173b00..c43a8f3 100644 --- a/tests/test_flex.py +++ b/tests/test_flex.py @@ -52,9 +52,9 @@ def test_flex_initialization(): with pytest.raises(ValueError): flex.FLEX(rscl, mmax, nmax, R, True, mass, velocity) with pytest.raises(ValueError): - flex.FLEX(rscl, mmax, nmax, R, phi, True, velocity) + flex.FLEX(rscl, mmax, nmax, R, phi, mass='nonsense') with pytest.raises(ValueError): - flex.FLEX(rscl, mmax, nmax, R, phi, mass, True) + flex.FLEX(rscl, mmax, nmax, R, phi, velocity='nonsense') def test_flex_version(): assert isinstance(flex.__version__, str) From 9cbb5aea2d501034c13aaa34e114534fe6a5b473 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 17:21:49 +0000 Subject: [PATCH 5/7] add coverage badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 170b2aa..35fb860 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/ObservationalExpansions/flex/blob/main/LICENSE) - +[![Coverage Status](https://coveralls.io/repos/github/ObservationalExpansions/flex/badge.svg?branch=main)](https://coveralls.io/github/ObservationalExpansions/flex?branch=main) ## Installation From bdcdfe6d25e790b4bfb7f293c4d0051eeb3b6594 Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 25 Nov 2025 17:29:13 +0000 Subject: [PATCH 6/7] Update .github/workflows/test.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ebbb465..e94a92f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,6 +29,7 @@ jobs: run: | coverage run -m pytest -v -s - name: Upload coverage to Coveralls + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' run: coveralls --service=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7d6c9983c2b88812c4b5c352e37f960ff098d731 Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 25 Nov 2025 17:29:26 +0000 Subject: [PATCH 7/7] Update tests/test_flex.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_flex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_flex.py b/tests/test_flex.py index c43a8f3..7c59807 100644 --- a/tests/test_flex.py +++ b/tests/test_flex.py @@ -113,7 +113,7 @@ def test_flex_total_normalisation(): F = flex.FLEX(rscl, mmax, nmax, R, phi, mass) - F.laguerre_reconstruction(R,phi) + F.laguerre_reconstruction(R, phi) # check the values for the norm #print(F.reconstruction)