Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#49)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)
- [github.com/psf/black: 24.4.0 → 24.10.0](psf/black@24.4.0...24.10.0)

* Update testing.yml

* change likelihood name

* add foreground

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add foregrounds

* upgrade data files

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Xavier Garrido <xavier.garrido@gmail.com>
  • Loading branch information
pre-commit-ci[bot] and xgarrido authored Oct 8, 2024
1 parent 3e62e93 commit cbf1213
Show file tree
Hide file tree
Showing 11 changed files with 59,354 additions and 68,389 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v4
Expand All @@ -27,8 +28,7 @@ jobs:
- name: Set gfortran link on macos-latest
if: matrix.os == 'macos-latest'
run: |
set -x
sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
ln -s gfortran-12 $(dirname $(which gfortran-12))/gfortran
gfortran --version
- name: Install dependencies via pip
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -16,7 +16,7 @@ repos:
exclude: docs/tutorials

- repo: https://github.com/psf/black
rev: "24.4.0"
rev: "24.10.0"
hooks:
- id: black
- id: black-jupyter
10 changes: 8 additions & 2 deletions cobaya_utilities/fisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ def compute_fisher_matrix(
**likelihood_info,
**{
"params": _get_sampled_params(params),
"theory": {"camb": {"extra_args": {"lens_potential_accuracy": 1}}},
"theory": {
"camb": {"extra_args": {"lens_potential_accuracy": 1}},
"mflike.BandpowerForeground": None,
},
},
}

model = get_model(info, packages_path=packages_path)
likelihood = model.likelihood[likelihood_name]
theory = model.theory["camb"]
foregrounds = model.theory["mflike.BandpowerForeground"]

# First grab the constant params and then update with the sampled one. We finally check for
# missing parameters
Expand All @@ -107,7 +111,9 @@ def _get_power_spectra(epsilon):
}
)
model.logposterior(point)
return likelihood._get_power_spectra(theory.get_Cl(ell_factor=True), **point)
return likelihood._get_power_spectra(
theory.get_Cl(ell_factor=True), foregrounds.get_fg_totals(), **point
)

delta = (_get_power_spectra(+epsilon) - _get_power_spectra(-epsilon)) / 2 / epsilon
if defaults[param] != 0:
Expand Down
3,918 changes: 1,679 additions & 2,239 deletions cobaya_utilities/tests/data/chains/mcmc.1.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cobaya_utilities/tests/data/chains/mcmc.covmat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# a b
8.989244019214552572e-02 4.245564610023024738e-02
4.245564610023024738e-02 1.720198303808555818e-01
8.199574334476460169e-02 3.315608477928922576e-02
3.315608477928921882e-02 1.566113685937853273e-01
123,733 changes: 57,628 additions & 66,105 deletions cobaya_utilities/tests/data/chains/mcmc.log

Large diffs are not rendered by default.

51 changes: 22 additions & 29 deletions cobaya_utilities/tests/data/chains/mcmc.progress
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
# N timestamp acceptance_rate Rminus1 Rminus1_cl
64.000000 2023-04-04T12:26:16.479221 0.201893 0.468959 NaN
128.000000 2023-04-04T12:26:16.638957 0.230631 0.128617 NaN
192.000000 2023-04-04T12:26:16.760950 0.26087 0.036854 NaN
256.000000 2023-04-04T12:26:16.891122 0.29124 0.069107 NaN
320.000000 2023-04-04T12:26:17.004582 0.317776 0.092753 NaN
384.000000 2023-04-04T12:26:17.133308 0.318144 0.057716 NaN
448.000000 2023-04-04T12:26:17.266454 0.31728 0.088818 NaN
512.000000 2023-04-04T12:26:17.407262 0.317421 0.079942 NaN
576.000000 2023-04-04T12:26:17.539775 0.326901 0.073043 NaN
640.000000 2023-04-04T12:26:17.694220 0.321447 0.060883 NaN
704.000000 2023-04-04T12:26:17.822126 0.321314 0.047169 NaN
768.000000 2023-04-04T12:26:17.947060 0.320534 0.023891 NaN
832.000000 2023-04-04T12:26:18.094098 0.316591 0.03396 NaN
896.000000 2023-04-04T12:26:18.223429 0.316832 0.051742 NaN
960.000000 2023-04-04T12:26:18.364227 0.314136 0.019223 NaN
1024.000000 2023-04-04T12:26:18.508209 0.309646 0.007569 NaN
1088.000000 2023-04-04T12:26:18.623970 0.312285 0.016516 NaN
1152.000000 2023-04-04T12:26:18.771142 0.310345 0.019428 NaN
1216.000000 2023-04-04T12:26:18.915678 0.308865 0.01046 NaN
1280.000000 2023-04-04T12:26:19.055133 0.308137 0.015631 NaN
1344.000000 2023-04-04T12:26:19.188437 0.307551 0.023413 NaN
1408.000000 2023-04-04T12:26:19.340717 0.305423 0.026334 NaN
1472.000000 2023-04-04T12:26:19.467083 0.30622 0.015438 NaN
1536.000000 2023-04-04T12:26:19.597414 0.305246 0.007206 NaN
1600.000000 2023-04-04T12:26:19.735379 0.304298 0.010107 NaN
1664.000000 2023-04-04T12:26:19.883041 0.30365 0.007922 NaN
1728.000000 2023-04-04T12:26:20.017143 0.302839 0.012971 NaN
1792.000000 2023-04-04T12:26:20.166836 0.301176 0.009886 NaN
1856.000000 2023-04-04T12:26:20.293572 0.301641 0.005365 0.096527
64.0 2024-10-08T09:48:32.105775 0.201893 0.476479 NaN
128.0 2024-10-08T09:48:32.260897 0.249513 0.212267 NaN
192.0 2024-10-08T09:48:32.435399 0.254305 0.031789 NaN
256.0 2024-10-08T09:48:32.559366 0.294931 0.03945 NaN
320.0 2024-10-08T09:48:32.729418 0.299065 0.031068 NaN
384.0 2024-10-08T09:48:32.905298 0.28764 0.057857 NaN
448.0 2024-10-08T09:48:33.057740 0.287364 0.013654 NaN
512.0 2024-10-08T09:48:33.194020 0.295783 0.022733 NaN
576.0 2024-10-08T09:48:33.346912 0.297828 0.015326 NaN
640.0 2024-10-08T09:48:33.520484 0.294795 0.022256 NaN
704.0 2024-10-08T09:48:33.663743 0.300085 0.018617 NaN
768.0 2024-10-08T09:48:33.832003 0.300352 0.008063 NaN
832.0 2024-10-08T09:48:33.992033 0.299173 0.015152 NaN
896.0 2024-10-08T09:48:34.155622 0.297674 0.045098 NaN
960.0 2024-10-08T09:48:34.293355 0.301129 0.026661 NaN
1024.0 2024-10-08T09:48:34.434713 0.304853 0.023714 NaN
1088.0 2024-10-08T09:48:34.593731 0.303741 0.015738 NaN
1152.0 2024-10-08T09:48:34.776615 0.299143 0.016022 NaN
1216.0 2024-10-08T09:48:34.948338 0.297602 0.0212 NaN
1280.0 2024-10-08T09:48:35.119579 0.296915 0.020767 NaN
1344.0 2024-10-08T09:48:35.295231 0.295385 0.009107 NaN
1408.0 2024-10-08T09:48:35.443081 0.29736 0.005808 0.104905
4 changes: 2 additions & 2 deletions cobaya_utilities/tests/data/chains/mcmc.updated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ sampler:
oversample: null
drag_limits: null
fallback_covmat_scale: 4
version: '3.3'
version: 3.5.4
output: mcmc
version: '3.3'
version: 3.5.4
5 changes: 3 additions & 2 deletions cobaya_utilities/tests/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def generate_mcmc():


def generate_pickle(data):
pickle.dump(data, open(os.path.join(data_path, "reference.pkl"), "wb"))
with open(os.path.join(data_path, "reference.pkl"), "wb") as f:
pickle.dump(data, f)


def get_reference():
Expand Down Expand Up @@ -135,7 +136,7 @@ def generate_chains():

all_params = {**cosmo_params, **nuisance_params}

likelihood_name = "mflike.MFLike"
likelihood_name = "mflike.TTTEEE"
likelihood_config = {
"input_file": "LAT_simu_sacc_00000.fits",
"cov_Bbl_file": "data_sacc_w_covar_and_Bbl.fits",
Expand Down
8 changes: 5 additions & 3 deletions cobaya_utilities/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def get_sampled_parameters(
if len(found) == 0:
continue
param, loc, scale = found[0]
external_priors[param] = f"$\mathcal{{G}}({float(loc)}, {float(scale)})$"
external_priors[param] = rf"$\mathcal{{G}}({float(loc)}, {float(scale)})$"
for param in sampled_params.get(name, []):
if param not in (params := updated_yaml.get("params")):
raise ValueError("Sampled paremeter can not be found within input parameters !")
Expand All @@ -627,11 +627,13 @@ def get_sampled_parameters(
if dist == "norm":
loc, scale = input_priors.get("loc"), input_priors.get("scale")
params_info.setdefault((name, "prior"), []).append(
f"$\mathcal{{G}}({loc}, {scale})$"
rf"$\mathcal{{G}}({loc}, {scale})$"
)
elif input_priors.get("min") or input_priors.get("max"):
min, max = input_priors.get("min"), input_priors.get("max")
params_info.setdefault((name, "prior"), []).append(f"$\mathcal{{U}}({min}, {max})$")
params_info.setdefault((name, "prior"), []).append(
rf"$\mathcal{{U}}({min}, {max})$"
)

# print(params_info)
df = pd.DataFrame.from_dict(params_info, orient="index").T.fillna("").drop_duplicates()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
"Topic :: Education",
]
requires-python = ">=3.9.0"
dependencies = ["cobaya>=3.4.1", "seaborn", "tqdm"]
dependencies = ["cobaya>=3.4.1", "seaborn", "tqdm", "jinja2"]

[project.optional-dependencies]
test = ["pytest", "pytest-cov", "camb", "mflike"]
Expand Down

0 comments on commit cbf1213

Please sign in to comment.