Rework GaussianLikelihood#218
Conversation
|
Generally seems fine to me at a quick skim. |
There was a problem hiding this comment.
Pull request overview
This PR reworks the GaussianLikelihood class to directly handle SACC (Standard ASCII Catalog of Cosmology) files, eliminating the need for intermediate PSLikelihood and BinnedPSLikelihood abstractions. The PR also renames CrossCorrelationLikelihood to CCLTracersLikelihood with clearer inheritance hierarchy, adding CCLTracersCrossLikelihood and CCLTracersAutoLikelihood subclasses to distinguish between cross-correlation and auto-correlation likelihoods.
Key Changes:
- Refactored
GaussianLikelihoodto directly load SACC files and handle tracer validation, binning, and covariance matrices - Renamed and restructured
cross_correlationmodule toccl_tracerswith clearer class hierarchy - Updated
LensingLikelihoodandLensingLiteLikelihoodto inherit directly fromGaussianLikelihoodinstead ofBinnedPSLikelihood - Moved
CrossCovclass fromgaussian.pytogaussian_data.pyand enhanced it with SACC file save/load capabilities - Added conversion scripts to migrate legacy FITS data to SACC format
Reviewed changes
Copilot reviewed 32 out of 38 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| soliket/gaussian/gaussian.py | Refactored GaussianLikelihood to handle SACC files directly with tracer validation and binning |
| soliket/gaussian/gaussian_data.py | Moved CrossCov class here and added SACC save/load functionality with metadata handling |
| soliket/ccl_tracers/ccl_tracers.py | Renamed from cross_correlation with new hierarchy: CCLTracersLikelihood, CCLTracersCrossLikelihood, CCLTracersAutoLikelihood |
| soliket/lensing/lensing.py | Changed to inherit from GaussianLikelihood; added SACC-based fiducial and correction factor loading |
| soliket/xcorr/xcorr.py | Updated to use new GaussianLikelihood structure with SACC data handling |
| soliket/ps/ps.py | Simplified PSLikelihood by removing redundant methods |
| tests/test_ps.py | Updated ToyLikelihood to use SACC files; enhanced CrossCov testing |
| tests/test_xcorr.py | Simplified test setup using dict-based info instead of YAML strings |
| tests/test_lensing.py | Added fixed_lensing_data fixture dependency and test for fiducial regeneration |
| tests/test_lensing_lite.py | Added required attributes (ls, use_spectra) for compatibility |
| tests/test_ccl_tracers_like.py | Renamed imports from cross_correlation to ccl_tracers |
| tests/conftest.py | Added fixed_lensing_data fixture to automatically convert FITS to SACC format |
| scripts/convert_to_sacc/lensing_fits_to_sacc.py | Script to convert legacy lensing FITS files to SACC format |
| .github/workflows/testing.yml | Changed fail-fast to true and added caching for venv and cobaya packages |
| pyproject.toml | Updated package list and coverage exclusions |
| docs/crosscorrelation.rst | Updated documentation to reference ccl_tracers instead of cross_correlation |
Comments suppressed due to low confidence (4)
soliket/ccl_tracers/ccl_tracers.py:132
- The error message uses backslash line continuations within a string literal, which adds unwanted whitespace to the error message. This should be written as a single line or use parentheses for implicit line continuation.
soliket/ccl_tracers/ccl_tracers.py:103 - The error message uses backslash line continuations within a string literal, which adds unwanted whitespace to the error message. This should be written as a single line or use parentheses for implicit line continuation.
tests/test_runs.py:79 - Tests for "lensing" and "multi" likelihoods are commented out in the parametrize decorators. This reduces test coverage for these important likelihoods. If these tests are failing, they should be fixed rather than disabled, or at minimum a TODO comment should explain why they're disabled and when they'll be re-enabled.
scripts/convert_to_sacc/lensing_fits_to_sacc.py:13 - This assignment to 'packages_path' is unnecessary as it is redefined before this value is used.
packages_path = resolve_packages_path()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
In the last office hour (30/09/25), we discussed the homogeneity of input files format and re-stated the need to have
saccfiles everywhere (see also #31 #58 #61).I had a look at the code in this sense, and I think that reworking the
GaussianLikelihoodis a way to tackle this. Indeed, the current likelihood is quite general for whatever Gaussian variable, then thePSLikelihoodspecializes it to power spectra, and theBinnedPSLikelihoodto binned power spectra. All of them lack the interface tosaccfiles, though, which at the moment is delegated to specific incarnations of those (e.g.,CrossCorrelationLikelihood).However, I am not sure we need all this complexity. So, in this PR, I am reworking the
GaussianLikelihoodto deal withsaccfiles and to get inherited directly by likelihoods asLensingLikelihood, similarly to what already happens forCrossCorrelationLikelihood. This allows us to avoid code duplication and to have N likelihoods that deal withsaccin N different ways.Also, linked to this,
CrossCorrelationLikelihoodneeds a little "rebranding", in my opinion. For instance, it deals with cross-correlation of CCL tracers, but, as #206 proves, we may want to add auto-correlations.Thus, I propose a rename into
CCLTracersLikelihood, from which I defineCCLTracersCrossLikelihoodandCCLTracersAutoLikelihoodto have a clear inheritance structure to build stuff likeShearShearLikelihood.On a more structural level, right now I am implementing all the necessary things directly in
GaussianLikelihood, but eventually we could still maintain aPSLikelihoodwith power-spectra-specialized stuff. However, it is not strictly necessary I guess.@mgerbino, @itrharrison, @cmbant, since this will touch a large part of the repo, I think it would be extremely valuable to have your opinion on this.