Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,680 changes: 1,374 additions & 1,306 deletions .github/conda-lock/py3.12.conda-lock.yml

Large diffs are not rendered by default.

2,679 changes: 1,373 additions & 1,306 deletions .github/conda-lock/py3.13.conda-lock.yml

Large diffs are not rendered by default.

2,722 changes: 1,394 additions & 1,328 deletions .github/conda-lock/py3.14.conda-lock.yml

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dependencies-validated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# firecrown-deps-validated metapackage.
#
# The digest records which environment.yml the lockfiles were solved
# from, so that pins left behind by a manifest edit are detected.
environment-sha256: "8ada10463b470da5f4f2d7d49d676498d471c635cd770c1a7037b927387edcf8"
# from as historical metadata; --check verifies constraints from locks.
environment-sha256: "52bad1a39356cd718b23ced5b6cbe6a2174801a7ab5109885c91a87b2c62bd6d"
constraints:
astropy: ">=8.0.1,<8.1"
astropy: ">=8.0.2,<8.1"
camb: ">=1.6.5,<1.7"
charset-normalizer: ">=3.5.1,<3.6"
clmm: ">=1.16.10,<1.17"
Expand All @@ -23,20 +23,20 @@ constraints:
idna: ">=3.20,<3.21"
lsstdesc-crow: ">=1.0.12,<1.1"
matplotlib-base: ">=3.11.2,<3.12"
more-itertools: ">=11.1.0,<11.2"
numcosmo: ">=0.27.0,<0.28"
more-itertools: ">=11.2.1,<11.3"
numcosmo: ">=0.28.0,<0.29"
numpy: ">=2.3.5,<2.4"
pip: ">=26.2.1,<26.3"
pip: ">=26.2.2,<26.3"
portalocker: ">=3.2.0,<3.3"
pybobyqa: ">=1.5.0,<1.6"
pyccl: ">=3.3.6,<3.4"
pydantic: ">=2.13.5,<2.14"
pydantic: ">=2.14.1,<2.15"
pyyaml: ">=6.0.3,<6.1"
rich: ">=15.0.0,<15.1"
sacc: ">=2.4,<2.5"
scipy: ">=1.18.1,<1.19"
tabulate: ">=0.10.0,<0.11"
typer: ">=0.27.2,<0.28"
typer: ">=0.27.3,<0.28"
types-pyyaml: ">=6.0.12.20260906,<6.1"
typing_extensions: ">=4.16.0,<4.17"
urllib3: ">=2.8.0,<2.9"
7 changes: 5 additions & 2 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ runtime:
conda: false
note: cobaya connector; not packaged on conda-forge
- name: cosmosis
version: ">=3.0"
version: ">=3.0,<3.26"
note: 3.26 .mod files need gfortran 15; camb <2.0 holds compilers at 14
- name: cosmosis-build-standard-library
pip: false
import: false
Expand All @@ -71,7 +72,7 @@ runtime:
import: matplotlib
note: firecrown sacc view
- name: numcosmo
version: ">=0.27"
version: ">=0.28,<1.0"
pip: numcosmo_py
import: numcosmo_py
- name: numpy
Expand Down Expand Up @@ -121,6 +122,8 @@ devenv:
- name: pandas
note: tutorials
- name: plotnine
- name: pygobject-stubs
version: "<2.18"
- name: pylint
- name: pytest
- name: pytest-cov
Expand Down
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- charset-normalizer
- clmm # part of the DESC stack; needed indirectly through lsstdesc-crow
- compilers # two-phase cosmosis-standard-library installation
- cosmosis >=3.0
- cosmosis >=3.0,<3.26 # 3.26 .mod files need gfortran 15; camb <2.0 holds compilers at 14
- cosmosis-build-standard-library
- coverage
- cython
Expand All @@ -33,7 +33,7 @@ dependencies:
- matplotlib-base # firecrown sacc view
- more-itertools
- mypy
- numcosmo >=0.27
- numcosmo >=0.28,<1.0
- numpy >=2.0,<2.4
- pandas # tutorials
- pip >=20.1 # installs cobaya, which conda-forge does not package
Expand All @@ -46,6 +46,7 @@ dependencies:
- pybobyqa
- pyccl >=2.8.0
- pydantic
- pygobject-stubs <2.18
- pylint
- pytest
- pytest-cov
Expand Down
10 changes: 5 additions & 5 deletions firecrown/app/analysis/_numcosmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ def _setup_cosmology(

assert mapping is not None

prim = Nc.HIPrimPowerLaw.new() # pylint: disable=no-value-for-parameter
reion = Nc.HIReionCamb.new() # pylint: disable=no-value-for-parameter
cosmo = Nc.HICosmoDECpl(
massnu_length=options.cosmo_spec.get_num_massive_neutrinos()
massnu_length=options.cosmo_spec.get_num_massive_neutrinos(),
prim=prim,
reion=reion,
)
cosmo.omega_x2omega_k()
prim = Nc.HIPrimPowerLaw.new() # pylint: disable=no-value-for-parameter
reion = Nc.HIReionCamb.new() # pylint: disable=no-value-for-parameter
cosmo.add_submodel(prim)
cosmo.add_submodel(reion)
mset.set(cosmo)

_set_standard_params(options, mset, cosmo, prim, reion, priors)
Expand Down
4 changes: 1 addition & 3 deletions firecrown/app/examples/_cluster_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,9 @@ class StackedProfiles:

def _numcosmo_cosmology() -> Nc.HICosmoDEXcdm:
"""Create the fiducial NumCosmo cosmology normalized to sigma8."""
cosmo = Nc.HICosmoDEXcdm()
reion = Nc.HIReionCamb.new() # pylint: disable=no-value-for-parameter
prim = Nc.HIPrimPowerLaw.new() # pylint: disable=no-value-for-parameter
cosmo.add_submodel(reion)
cosmo.add_submodel(prim)
cosmo = Nc.HICosmoDEXcdm(prim=prim, reion=reion)

psml = Nc.PowspecMLTransfer.new(
Nc.TransferFuncEH.new() # pylint: disable=no-value-for-parameter
Expand Down
4 changes: 3 additions & 1 deletion firecrown/likelihood/_binned_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from abc import ABC

import numpy as np
from crow.properties import ClusterProperty
from crow.recipes.binned_parent import (
Expand All @@ -20,7 +22,7 @@
from firecrown.models.cluster import ClusterData, SaccBin


class BinnedCluster(Statistic):
class BinnedCluster(Statistic, ABC):
"""A statistic representing clusters in a z, mass bin."""

def __init__(
Expand Down
3 changes: 2 additions & 1 deletion firecrown/likelihood/_gaussfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import warnings
from abc import ABC
from collections.abc import Callable, Sequence
from enum import Enum
from functools import wraps
Expand Down Expand Up @@ -113,7 +114,7 @@ def wrapper_repeat(*args: P.args, **kwargs: P.kwargs) -> T:
return decorator_enforce_states


class GaussFamily(Likelihood):
class GaussFamily(Likelihood, ABC):
"""GaussFamily is the base class for likelihoods based on a chi-squared calculation.

It provides an implementation of Likelihood.compute_chisq. Derived classes must
Expand Down
10 changes: 10 additions & 0 deletions firecrown/likelihood/_student_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import cast

import numpy as np
import numpy.typing as npt

from firecrown.likelihood._gaussfamily import GaussFamily
from firecrown.likelihood_base import Statistic
Expand Down Expand Up @@ -43,3 +44,12 @@ def compute_loglike(self, tools: ModelingTools) -> float:
"""
chi2 = self.compute_chisq(tools)
return -0.5 * self.nu * np.log(1.0 + chi2 / (self.nu - 1.0))

def make_realization_vector(self) -> npt.NDArray[np.float64]:
"""Create a new realization of the model.

Realizations are not available for the Student-t likelihood.

:raises NotImplementedError: always.
"""
raise NotImplementedError("StudentT does not support realizations.")
7 changes: 4 additions & 3 deletions firecrown/likelihood_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from __future__ import annotations

import warnings
from abc import abstractmethod
from abc import ABC, abstractmethod
from collections.abc import Mapping, Sequence
from dataclasses import dataclass, replace
from typing import Annotated, Generic, Literal, TypeVar, cast, final
Expand Down Expand Up @@ -1107,9 +1107,11 @@ def apply(
return replace(tracer_arg, field=self.field)


class SourceGalaxy(Source, Generic[_SourceGalaxyArgsT]):
class SourceGalaxy(Source, Generic[_SourceGalaxyArgsT], ABC):
"""Source class for galaxy based sources."""

tracer_args: _SourceGalaxyArgsT

def __init__(
self,
*,
Expand All @@ -1129,7 +1131,6 @@ def __init__(
self.systematics: UpdatableCollection[
SourceGalaxySystematic[_SourceGalaxyArgsT]
] = UpdatableCollection(systematics)
self.tracer_args: _SourceGalaxyArgsT

def read_systematics(self, sacc_data: sacc.Sacc) -> None:
"""Read the systematics for this source from the SACC file.
Expand Down
4 changes: 2 additions & 2 deletions firecrown/models/two_point/_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ def get_tracers_and_scales(
def generate_ells_for_interpolation(self) -> npt.NDArray[np.int64]:
"""Generate ells for interpolation."""
assert self.ells is not None
min_ell = int(self.ells[0])
max_ell = int(self.ells[-1])
min_ell = int(np.min(self.ells))
max_ell = int(np.max(self.ells))
return self.interp_ells_gen.generate(min_ell, max_ell)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ dependencies = [
"astropy",
"camb<2.0",
"cobaya",
"cosmosis>=3.0",
"cosmosis>=3.0,<3.26",
"fitsio",
"isitgr",
"lsstdesc-crow",
"matplotlib",
"numcosmo_py>=0.27",
"numcosmo_py>=0.28,<1.0",
"numpy>=2.0,<2.4",
"pyccl>=2.8.0",
"pydantic",
Expand Down
3 changes: 1 addition & 2 deletions tests/app/analysis/test_numcosmo_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ def test_set_amplitude_a_s_no_prior(
)

# Create minimal NumCosmo objects with proper hierarchy
cosmo = Nc.HICosmoDECpl.new() # pylint: disable=no-value-for-parameter
prim = Nc.HIPrimPowerLaw.new() # pylint: disable=no-value-for-parameter
cosmo.add_submodel(prim)
cosmo = Nc.HICosmoDECpl(prim=prim)
mset = Ncm.MSet.new_array([cosmo])

priors: list[Ncm.Prior] = []
Expand Down
72 changes: 33 additions & 39 deletions tests/connector/numcosmo/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@
@pytest.fixture(name="numcosmo_cosmo_xcdm")
def fixture_numcosmo_cosmo_xcdm():
"""Create a NumCosmo cosmology instance of XCDM."""
cosmo = Nc.HICosmoDEXcdm(massnu_length=1)
prim = Nc.HIPrimPowerLaw.new()
prim.param_set_by_name( # pylint: disable=no-member
"ln10e10ASA", math.log(1.0e10 * 2.0e-09)
)
prim.param_set_by_name("n_SA", 0.971) # pylint: disable=no-member
reion = Nc.HIReionCamb.new()
bbn = Nc.BBNParametrized.new()
bbn.param_set_by_name("Yp", 0.2454) # pylint: disable=no-member

cosmo = Nc.HICosmoDEXcdm(massnu_length=1, prim=prim, reion=reion, bbn=bbn)
cosmo.omega_x2omega_k()
cosmo.param_set_by_name("H0", 68.2)
cosmo.param_set_by_name("Omegak", 0.0)
cosmo.param_set_by_name("Omegab", 0.022558514 / 0.682**2)
cosmo.param_set_by_name("Omegac", 0.118374058 / 0.682**2)
cosmo.param_set_by_name("massnu_0", 0.06)
cosmo.param_set_by_name("ENnu", 2.0328)
cosmo.param_set_by_name("Yp", 0.2454)
cosmo.param_set_by_name("w", -1.0)

prim = Nc.HIPrimPowerLaw.new()
prim.param_set_by_name( # pylint: disable=no-member
"ln10e10ASA", math.log(1.0e10 * 2.0e-09)
)
prim.param_set_by_name("n_SA", 0.971) # pylint: disable=no-member

reion = Nc.HIReionCamb.new()
reion.set_z_from_tau(cosmo, 0.0561) # pylint: disable=no-member

cosmo.add_submodel(prim)
cosmo.add_submodel(reion)
reion.set_z_from_tau(0.0561) # pylint: disable=no-member

p_ml = Nc.PowspecMLTransfer.new(Nc.TransferFuncEH.new())
p_mnl = Nc.PowspecMNLHaloFit.new(p_ml, 3.0, 1.0e-5)
Expand All @@ -44,27 +42,25 @@ def fixture_numcosmo_cosmo_xcdm():
@pytest.fixture(name="numcosmo_cosmo_xcdm_no_nu")
def fixture_numcosmo_cosmo_xcdm_no_nu():
"""Create a NumCosmo cosmology instance of XCDM without neutrinos."""
cosmo = Nc.HICosmoDEXcdm()
prim = Nc.HIPrimPowerLaw.new()
prim.param_set_by_name( # pylint: disable=no-member
"ln10e10ASA", math.log(1.0e10 * 2.0e-09)
)
prim.param_set_by_name("n_SA", 0.971) # pylint: disable=no-member
reion = Nc.HIReionCamb.new()
bbn = Nc.BBNParametrized.new()
bbn.param_set_by_name("Yp", 0.2454) # pylint: disable=no-member

cosmo = Nc.HICosmoDEXcdm(prim=prim, reion=reion, bbn=bbn)
cosmo.omega_x2omega_k()
cosmo.param_set_by_name("H0", 68.2)
cosmo.param_set_by_name("Omegak", 0.0)
cosmo.param_set_by_name("Omegab", 0.022558514 / 0.682**2)
cosmo.param_set_by_name("Omegac", 0.118374058 / 0.682**2)
cosmo.param_set_by_name("ENnu", 3.046)
cosmo.param_set_by_name("Yp", 0.2454)
cosmo.param_set_by_name("w", -1.0)

prim = Nc.HIPrimPowerLaw.new()
prim.param_set_by_name( # pylint: disable=no-member
"ln10e10ASA", math.log(1.0e10 * 2.0e-09)
)
prim.param_set_by_name("n_SA", 0.971) # pylint: disable=no-member

reion = Nc.HIReionCamb.new()
reion.set_z_from_tau(cosmo, 0.0561) # pylint: disable=no-member

cosmo.add_submodel(prim)
cosmo.add_submodel(reion)
reion.set_z_from_tau(0.0561) # pylint: disable=no-member

p_ml = Nc.PowspecMLTransfer.new(Nc.TransferFuncEH.new())
p_mnl = Nc.PowspecMNLHaloFit.new(p_ml, 3.0, 1.0e-5)
Expand All @@ -79,28 +75,26 @@ def fixture_numcosmo_cosmo_cpl():
"""Create a NumCosmo cosmology instance using CPL parametrization for the dark
energy equation of state."""

cosmo = Nc.HICosmoDECpl()
prim = Nc.HIPrimPowerLaw.new()
prim.param_set_by_name( # pylint: disable=no-member
"ln10e10ASA", math.log(1.0e10 * 2.0e-09)
)
prim.param_set_by_name("n_SA", 0.971) # pylint: disable=no-member
reion = Nc.HIReionCamb.new()
bbn = Nc.BBNParametrized.new()
bbn.param_set_by_name("Yp", 0.2454) # pylint: disable=no-member

cosmo = Nc.HICosmoDECpl(prim=prim, reion=reion, bbn=bbn)
cosmo.omega_x2omega_k()
cosmo.param_set_by_name("H0", 68.2)
cosmo.param_set_by_name("Omegak", 0.0)
cosmo.param_set_by_name("Omegab", 0.022558514 / 0.682**2)
cosmo.param_set_by_name("Omegac", 0.118374058 / 0.682**2)
cosmo.param_set_by_name("ENnu", 3.046)
cosmo.param_set_by_name("Yp", 0.2454)
cosmo.param_set_by_name("w0", -1.0)
cosmo.param_set_by_name("w1", 0.1)

prim = Nc.HIPrimPowerLaw.new()
prim.param_set_by_name( # pylint: disable=no-member
"ln10e10ASA", math.log(1.0e10 * 2.0e-09)
)
prim.param_set_by_name("n_SA", 0.971) # pylint: disable=no-member

reion = Nc.HIReionCamb.new()
reion.set_z_from_tau(cosmo, 0.0561) # pylint: disable=no-member

cosmo.add_submodel(prim)
cosmo.add_submodel(reion)
reion.set_z_from_tau(0.0561) # pylint: disable=no-member

p_ml = Nc.PowspecMLTransfer.new(Nc.TransferFuncEH.new())
p_mnl = Nc.PowspecMNLHaloFit.new(p_ml, 3.0, 1.0e-5)
Expand Down
8 changes: 2 additions & 6 deletions tests/connector/numcosmo/test_numcosmo_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,7 @@ def test_numcosmo_data_pure_ccl_mode():
model.params_set_default_ftype()

# Create a basic cosmology model as well
cosmo = Nc.HICosmoDEXcdm()
cosmo.add_submodel(Nc.HIPrimPowerLaw.new())
cosmo.add_submodel(Nc.HIReionCamb.new())
cosmo = Nc.HICosmoDEXcdm(prim=Nc.HIPrimPowerLaw.new(), reion=Nc.HIReionCamb.new())

mset = Ncm.MSet()
mset.set(cosmo)
Expand Down Expand Up @@ -569,9 +567,7 @@ def test_numcosmo_gauss_cov_pure_ccl_mode():
model.params_set_default_ftype()

# Create a basic cosmology model as well
cosmo = Nc.HICosmoDEXcdm()
cosmo.add_submodel(Nc.HIPrimPowerLaw.new())
cosmo.add_submodel(Nc.HIReionCamb.new())
cosmo = Nc.HICosmoDEXcdm(prim=Nc.HIPrimPowerLaw.new(), reion=Nc.HIReionCamb.new())

mset = Ncm.MSet()
mset.set(cosmo)
Expand Down
Loading
Loading