From 0cf177d9503bc27c2839f5c142f8c756aa5983e9 Mon Sep 17 00:00:00 2001 From: Marc Paterno Date: Tue, 15 Oct 2024 15:38:45 -0500 Subject: [PATCH] Remove non-functional stub of halo model support --- firecrown/likelihood/source.py | 16 +--------------- firecrown/models/two_point.py | 3 --- tests/conftest.py | 19 +++++++++++++++++++ .../statistic/source/test_source.py | 17 +---------------- tests/test_models_twopoint.py | 16 ++++++++++++++++ 5 files changed, 37 insertions(+), 34 deletions(-) diff --git a/firecrown/likelihood/source.py b/firecrown/likelihood/source.py index 7ddafc28..2e1a11dd 100644 --- a/firecrown/likelihood/source.py +++ b/firecrown/likelihood/source.py @@ -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 @@ -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. @@ -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: @@ -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 diff --git a/firecrown/models/two_point.py b/firecrown/models/two_point.py index c88a4aea..8efc3986 100644 --- a/firecrown/models/two_point.py +++ b/firecrown/models/two_point.py @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index d135c1f4..d120c424 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,6 +7,7 @@ from itertools import product import pytest +import pyccl import sacc import numpy as np @@ -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, @@ -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.""" diff --git a/tests/likelihood/gauss_family/statistic/source/test_source.py b/tests/likelihood/gauss_family/statistic/source/test_source.py index 0041335f..df70d613 100644 --- a/tests/likelihood/gauss_family/statistic/source/test_source.py +++ b/tests/likelihood/gauss_family/statistic/source/test_source.py @@ -14,7 +14,6 @@ from firecrown.modeling_tools import ModelingTools from firecrown.likelihood.source import ( - Tracer, SourceGalaxy, SourceGalaxyArgs, SourceGalaxySelectField, @@ -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( @@ -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): @@ -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(): diff --git a/tests/test_models_twopoint.py b/tests/test_models_twopoint.py index 92cdf5e7..e7d91060 100644 --- a/tests/test_models_twopoint.py +++ b/tests/test_models_twopoint.py @@ -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(): @@ -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, + )