Skip to content

Commit

Permalink
restore include/exclude parameters for spectra
Browse files Browse the repository at this point in the history
  • Loading branch information
ntessore committed Nov 25, 2024
1 parent 8a2b477 commit 7769902
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion heracles/twopoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import numpy as np

from .core import TocDict, update_metadata
from .core import TocDict, toc_match, update_metadata
from .progress import NoProgress, Progress
from .result import Result, binned

Expand Down Expand Up @@ -181,6 +181,8 @@ def angular_power_spectra(
debias=True,
bins=None,
weights=None,
include=None,
exclude=None,
out=None,
):
"""compute angular power spectra from a set of alms"""
Expand Down Expand Up @@ -226,6 +228,10 @@ def angular_power_spectra(
else:
swapped = False

# check if cl is skipped by explicit include or exclude list
if not toc_match((k1, k2, i1, i2), include, exclude):
continue

logger.info("computing %s x %s cl for bins %s, %s", k1, k2, i1, i2)

# retrieve alms from keys; make sure swap is respected
Expand Down
13 changes: 13 additions & 0 deletions tests/test_twopoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ def test_angular_power_spectra(mock_alms, lmax):
for key, cl in cls.items():
assert cl.shape == comb12[key]

# include and exclude
inc = object()
exc = object()
with patch("heracles.twopoint.toc_match") as mock_match:
mock_match.return_value = False
cls = angular_power_spectra(mock_alms1, mock_alms2, include=inc, exclude=exc)
assert len(cls) == 0
assert mock_match.call_count == len(comb12)
call_iter = iter(mock_match.call_args_list)
for a, i in mock_alms1:
for b, j in mock_alms2:
assert next(call_iter) == call((a, b, i, j), inc, exc)


def test_debias_cls():
from heracles.twopoint import debias_cls
Expand Down

0 comments on commit 7769902

Please sign in to comment.