Skip to content

Commit 23ee4b6

Browse files
authored
Test assign (#408)
* maintain order of existing defined input_params * fix * bump version
1 parent 681130c commit 23ee4b6

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2+
## 3.5.7 - 2025-03-31
3+
4+
### General
5+
6+
- Fixed issue with changing parameter order using gaussian_mixture with input_params
7+
- cobaya-doc can be used to list components of a given type, e.g. `cobaya-doc bao`
8+
- Small tidies for float output with numpy2
9+
10+
### Cosmology
11+
12+
- BAO, DESI, and SN likelihood docs now automatically list all available internal likelihoods
13+
114
## 3.5.6 - 2025-03-21
215

316
### Cosmology

cobaya/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "Jesus Torrado and Antony Lewis"
2-
__version__ = "3.5.6"
2+
__version__ = "3.5.7"
33
__obsolete__ = False
44
__year__ = "2025"
55
__url__ = "https://cobaya.readthedocs.io"

cobaya/likelihoods/bao/desi_dr2/desi_bao_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
class desi_bao_all(BAO):
55
r"""
6-
DESI BAO likelihood for all tracers.
6+
DESI BAO likelihood for all tracers. (bao.desi_dr2 is same as desi_bao_all)
77
"""
88
bibtex_file = 'desi_dr2.bibtex'

cobaya/likelihoods/gaussian_mixture/gaussian_mixture.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,11 @@ def d(self):
4141
"""
4242
return len(self.input_params)
4343

44-
def initialize(self):
45-
super().initialize()
46-
self._input_params_order = self.input_params
47-
48-
4944
def initialize_with_params(self):
5045
"""
5146
Initializes the gaussian distributions.
5247
"""
5348
self.log.debug("Initializing")
54-
self._input_params_order = self._input_params_order or self.input_params
5549
# Load mean and cov, and check consistency of n_modes and dimensionality
5650
if self.means is not None and self.covs is not None:
5751
# Wrap them in the right arrays (n_mode, param) and check consistency
@@ -126,7 +120,7 @@ def logp(self, **params_values):
126120
"""
127121
self.wait()
128122
# Prepare the vector of sampled parameter values
129-
x = np.array([params_values[p] for p in self._input_params_order])
123+
x = np.array([params_values[p] for p in self.input_params])
130124
# Fill the derived parameters
131125
derived = params_values.get("_derived")
132126
if derived is not None:

cobaya/model.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,11 +1079,18 @@ def _assign_params(self, info_likelihood, info_theory=None,
10791079
"Output params can only be computed by one likelihood/theory, "
10801080
"but some were claimed by more than one: %r.", multi_assigned_output)
10811081
# Finished! Assign and update infos
1082-
for assign, option in ((input_assign, "input_params"),
1083-
(output_assign, "output_params")):
1082+
for assign, option, output in ((input_assign, "input_params", False),
1083+
(output_assign, "output_params", True)):
10841084
for component in self.components:
1085-
setattr(component, option,
1086-
[p for p, assign in assign.items() if component in assign])
1085+
assign_params = [p for p, assign in assign.items() if component in assign]
1086+
current_assign = getattr(component, option)
1087+
if output or current_assign is unset_params:
1088+
setattr(component, option, assign_params)
1089+
elif set(assign_params) != set(current_assign):
1090+
raise LoggedError(
1091+
self.log, "exising %s %r do not match assigned parameters %r",
1092+
option, assign_params, current_assign)
1093+
10871094
# Update infos! (helper theory parameters stored in yaml with host)
10881095
inf = (info_likelihood if component in self.likelihood.values() else
10891096
info_theory)

0 commit comments

Comments
 (0)