Skip to content

Rework GaussianLikelihood#218

Merged
ggalloni merged 77 commits into
masterfrom
rework_gaussian
Jan 14, 2026
Merged

Rework GaussianLikelihood#218
ggalloni merged 77 commits into
masterfrom
rework_gaussian

Conversation

@ggalloni
Copy link
Copy Markdown
Collaborator

@ggalloni ggalloni commented Oct 6, 2025

In the last office hour (30/09/25), we discussed the homogeneity of input files format and re-stated the need to have sacc files everywhere (see also #31 #58 #61).

I had a look at the code in this sense, and I think that reworking the GaussianLikelihood is a way to tackle this. Indeed, the current likelihood is quite general for whatever Gaussian variable, then the PSLikelihood specializes it to power spectra, and the BinnedPSLikelihood to binned power spectra. All of them lack the interface to sacc files, 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 GaussianLikelihood to deal with sacc files and to get inherited directly by likelihoods as LensingLikelihood, similarly to what already happens for CrossCorrelationLikelihood. This allows us to avoid code duplication and to have N likelihoods that deal with sacc in N different ways.

Also, linked to this, CrossCorrelationLikelihood needs 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 define CCLTracersCrossLikelihood and CCLTracersAutoLikelihood to have a clear inheritance structure to build stuff like ShearShearLikelihood.

On a more structural level, right now I am implementing all the necessary things directly in GaussianLikelihood, but eventually we could still maintain a PSLikelihood with 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.

@cmbant
Copy link
Copy Markdown
Collaborator

cmbant commented Oct 6, 2025

Generally seems fine to me at a quick skim.
(Does seem a bit odd having separate CCLTracersLikelihood subclasses for auto and cross likelihoods (given that in general one should use everything with a full covariance). Maybe could do more general check on types of data that are included in each specific likelihood, but I've not looked at this for some time.)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GaussianLikelihood to directly load SACC files and handle tracer validation, binning, and covariance matrices
  • Renamed and restructured cross_correlation module to ccl_tracers with clearer class hierarchy
  • Updated LensingLikelihood and LensingLiteLikelihood to inherit directly from GaussianLikelihood instead of BinnedPSLikelihood
  • Moved CrossCov class from gaussian.py to gaussian_data.py and 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.

Comment thread .github/workflows/testing.yml Outdated
Comment thread .github/workflows/testing.yml Outdated
Comment thread soliket/gaussian/gaussian.py Outdated
Comment thread scripts/convert_to_sacc/lensing_fits_to_sacc.py Outdated
Comment thread soliket/gaussian/gaussian.py Outdated
Comment thread soliket/gaussian/gaussian.py
Comment thread tests/test_crosscov.py Outdated
Comment thread tests/test_lensing.py
Comment thread soliket/gaussian/gaussian_data.py
Comment thread scripts/convert_to_sacc/lensing_fits_to_sacc.py Outdated
@ggalloni ggalloni merged commit 1598e1d into master Jan 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants