Skip to content

Commit

Permalink
Remove non-functional stub of halo model support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpaterno committed Oct 15, 2024
1 parent 5165126 commit 0cf177d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
16 changes: 1 addition & 15 deletions firecrown/likelihood/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Tracer:
"""Extending the pyccl.Tracer object with additional information.
Bundles together a pyccl.Tracer object with optional information about the
underlying 3D field, a pyccl.nl_pt.PTTracer, and halo profiles.
underlying 3D field, or a pyccl.nl_pt.PTTracer.
"""

@staticmethod
Expand Down Expand Up @@ -160,8 +160,6 @@ def __init__(
tracer_name: None | str = None,
field: None | str = None,
pt_tracer: None | pyccl.nl_pt.PTTracer = None,
halo_profile: None | pyccl.halos.HaloProfile = None,
halo_2pt: None | pyccl.halos.Profile2pt = None,
):
"""Initialize a new Tracer based on the provided tracer.
Expand All @@ -178,16 +176,12 @@ def __init__(
:param tracer_name: optional name of the tracer.
:param field: optional name of the field associated with the tracer.
:param pt_tracer: optional non-linear perturbation theory tracer.
:param halo_profile: optional halo profile.
:param halo_2pt: optional halo profile 2-point object.
"""
assert tracer is not None
self.ccl_tracer = tracer
self.tracer_name: str = tracer_name or tracer.__class__.__name__
self.field = Tracer.determine_field_name(field, tracer_name)
self.pt_tracer = pt_tracer
self.halo_profile = halo_profile
self.halo_2pt = halo_2pt

@property
def has_pt(self) -> bool:
Expand All @@ -197,14 +191,6 @@ def has_pt(self) -> bool:
"""
return self.pt_tracer is not None

@property
def has_hm(self) -> bool:
"""Answer whether we have a halo profile.
:return: True if we have a halo_profile, and False if not.
"""
return self.halo_profile is not None


# Sources of galaxy distributions

Expand Down
3 changes: 0 additions & 3 deletions firecrown/models/two_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ def calculate_pk(pk_name: str, tools: ModelingTools, tracer0: Tracer, tracer1: T
tracer1=tracer0.pt_tracer,
tracer2=tracer1.pt_tracer,
)
elif tracer0.has_hm or tracer1.has_hm:
# Compute halo model power spectrum
raise NotImplementedError("Halo model power spectra not supported yet")
else:
raise ValueError(f"No power spectrum for {pk_name} can be found.")
return pk
Expand Down
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from itertools import product
import pytest

import pyccl
import sacc

import numpy as np
Expand All @@ -18,6 +19,7 @@
from firecrown.parameters import ParamsMap
from firecrown.connector.mapping import MappingCosmoSIS, mapping_builder
from firecrown.modeling_tools import ModelingTools
from firecrown.likelihood.source import Tracer
from firecrown.metadata_types import (
Galaxies,
InferredGalaxyZDist,
Expand Down Expand Up @@ -81,6 +83,23 @@ def _skip_tests(items, keyword, reason):
# Fixtures


class TrivialTracer(Tracer):
"""This is the most trivial possible subclass of Tracer."""

@property
def has_pt(self) -> bool:
"""Answer whether we have a perturbation theory tracer.
:return: False, becauswe this is a dummy tracer.
"""
return False


@pytest.fixture(name="empty_pyccl_tracer")
def fixture_empty_pyccl_tracer():
return pyccl.Tracer()


@pytest.fixture(name="trivial_stats")
def make_stats():
"""Return a non-empty list of TrivialStatistics."""
Expand Down
17 changes: 1 addition & 16 deletions tests/likelihood/gauss_family/statistic/source/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from firecrown.modeling_tools import ModelingTools
from firecrown.likelihood.source import (
Tracer,
SourceGalaxy,
SourceGalaxyArgs,
SourceGalaxySelectField,
Expand All @@ -23,15 +22,7 @@
import firecrown.likelihood.weak_lensing as wl
from firecrown.metadata_functions import extract_all_tracers_inferred_galaxy_zdists
from firecrown.parameters import ParamsMap


class TrivialTracer(Tracer):
"""This is the most trivial possible subclass of Tracer."""


@pytest.fixture(name="empty_pyccl_tracer")
def fixture_empty_pyccl_tracer():
return pyccl.Tracer()
from tests.conftest import TrivialTracer


@pytest.fixture(
Expand Down Expand Up @@ -103,10 +94,7 @@ def test_trivial_tracer_construction(empty_pyccl_tracer):
# field is "delta_matter".
assert trivial.field == "delta_matter"
assert trivial.pt_tracer is None
assert trivial.halo_profile is None
assert trivial.halo_2pt is None
assert not trivial.has_pt
assert not trivial.has_hm


def test_tracer_construction_with_name(empty_pyccl_tracer):
Expand All @@ -115,10 +103,7 @@ def test_tracer_construction_with_name(empty_pyccl_tracer):
assert named.tracer_name == "Fred"
assert named.field == "Fred"
assert named.pt_tracer is None
assert named.halo_profile is None
assert named.halo_2pt is None
assert not named.has_pt
assert not named.has_hm


def test_linear_bias_systematic():
Expand Down
16 changes: 16 additions & 0 deletions tests/test_models_twopoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import pytest
import firecrown.models.two_point as models
from firecrown.likelihood import source
import firecrown.modeling_tools as mt
from tests.conftest import TrivialTracer


def test_determine_ccl_kind():
Expand All @@ -18,3 +21,16 @@ def test_determine_ccl_kind():
assert models.determine_ccl_kind("cmbGalaxy_convergenceShear_xi_t") == "NG"
with pytest.raises(ValueError):
_ = models.determine_ccl_kind("bad_sacc_data_type")


def test_calculate_pk_lacking_pk(
tools_with_vanilla_cosmology: mt.ModelingTools, empty_pyccl_tracer: source.Tracer
):
dummy = TrivialTracer(empty_pyccl_tracer)
with pytest.raises(ValueError):
_ = models.calculate_pk(
"no such entry",
tools_with_vanilla_cosmology,
dummy,
dummy,
)

0 comments on commit 0cf177d

Please sign in to comment.