From c6be5bc31badc76cc409dbca0f2619b17bd59800 Mon Sep 17 00:00:00 2001 From: Santiago Casas Date: Tue, 24 Sep 2024 10:03:09 +0200 Subject: [PATCH] add codecov reports (#73) * add codecov reports * add codecov reports changelog * add codecov fix token * readme and new tests * Updated coverage.svg * add cov test * fish test * Updated coverage.svg * Merge branch 'main' into codecov --- .github/workflows/ci.yml | 4 ++++ CHANGELOG.md | 4 ++-- README.md | 2 +- coverage.svg | 4 ++-- tests/cosmicfish_test.py | 11 +++++++++++ tests/photo_cov_test.py | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 tests/photo_cov_test.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dba0a39..3d68fde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,10 @@ jobs: - name: Run tests run: | pytest + - name: Upload to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} - name: coverage.py badge uses: tj-actions/coverage-badge-py@v2.0.3 - name: Verify Changed files diff --git a/CHANGELOG.md b/CHANGELOG.md index b1459f1..9f626aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,5 +28,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 1.1.0 : Implemented symbolic as a new boltzmann solver class. Fixes of feedback prints. More docstrings. 1.1.1 : Resolved gcsp bias bug, new test suite. 1.1.2 : Coverage badge - -1.1.3 : New split up demonstration notebooks \ No newline at end of file +1.1.3 : New split up demonstration notebooks +1.1.4 : Coverage reports with Codecov \ No newline at end of file diff --git a/README.md b/README.md index 003e869..6fe3828 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # cosmicfishpie [![Documentation Status](https://readthedocs.org/projects/cosmicfishpie/badge/?version=latest)](https://cosmicfishpie.readthedocs.io/en/latest/?badge=latest) -![Coverage](./coverage.svg) +![Coverage](./coverage.svg) [![codecov](https://codecov.io/github/santiagocasas/cosmicfishpie/graph/badge.svg?token=BXTVDPXPUO)](https://codecov.io/github/santiagocasas/cosmicfishpie)
diff --git a/coverage.svg b/coverage.svg index d199f25..f78bcfc 100644 --- a/coverage.svg +++ b/coverage.svg @@ -15,7 +15,7 @@ coverage coverage - 33% - 33% + 35% + 35% diff --git a/tests/cosmicfish_test.py b/tests/cosmicfish_test.py index ab12ad3..99cc3b7 100644 --- a/tests/cosmicfish_test.py +++ b/tests/cosmicfish_test.py @@ -1,3 +1,4 @@ +from cosmicfishpie.analysis.fisher_operations import marginalise_over from cosmicfishpie.utilities.utils import printing as cpr @@ -13,3 +14,13 @@ def test_FisherMatrix(spectro_fisher_matrix): assert hasattr(fish, "fisher_matrix") assert hasattr(fish, "fisher_matrix_inv") assert hasattr(fish, "get_confidence_bounds") + + +def test_marginalise_over(spectro_fisher_matrix): + fish = spectro_fisher_matrix.compute(max_z_bins=1) + marginalized_fish = marginalise_over(fish, ["h"]) + assert hasattr(marginalized_fish, "fisher_matrix") + assert hasattr(marginalized_fish, "fisher_matrix_inv") + assert hasattr(marginalized_fish, "get_confidence_bounds") + assert hasattr(marginalized_fish, "get_param_names") + assert len(marginalized_fish.get_param_names()) == (1 + 2) diff --git a/tests/photo_cov_test.py b/tests/photo_cov_test.py new file mode 100644 index 0000000..d743d39 --- /dev/null +++ b/tests/photo_cov_test.py @@ -0,0 +1,35 @@ +from cosmicfishpie.LSSsurvey.photo_cov import PhotoCov + +# You might need to add more imports depending on what you're testing + + +def test_photo_cov_initialization(photo_fisher_matrix): + cosmopars = {"Omegam": 0.3, "h": 0.7} # Add more parameters as needed + cosmoFM = photo_fisher_matrix + photo_cov = PhotoCov(cosmopars, cosmoFM.photopars, cosmoFM.IApars, cosmoFM.biaspars) + assert isinstance(photo_cov, PhotoCov) + assert photo_cov.cosmopars == cosmopars + + +def test_get_cls(photo_fisher_matrix): + cosmoFM = photo_fisher_matrix + cosmopars = {"Omegam": 0.3, "h": 0.7} # Add more parameters as needed + photo_cov = PhotoCov(cosmopars, cosmoFM.photopars, cosmoFM.IApars, cosmoFM.biaspars) + allparsfid = dict() + allparsfid.update(cosmopars) + allparsfid.update(cosmoFM.IApars) + allparsfid.update(cosmoFM.biaspars) + allparsfid.update(cosmoFM.photopars) + cls = photo_cov.getcls(allparsfid) + assert isinstance(cls, dict) + # Add more specific assertions based on what you expect in the result + + +def test_get_cls_noise(photo_fisher_matrix): + cosmoFM = photo_fisher_matrix + cosmopars = {"Omegam": 0.3, "h": 0.7} # Add more parameters as needed + photo_cov = PhotoCov(cosmopars, cosmoFM.photopars, cosmoFM.IApars, cosmoFM.biaspars) + cls = photo_cov.getcls(photo_cov.allparsfid) + noisy_cls = photo_cov.getclsnoise(cls) + assert isinstance(noisy_cls, dict) + # Add more specific assertions based on what you expect in the result