Skip to content
Open
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
12 changes: 2 additions & 10 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,12 @@ jobs:
matrix:
include:
- os: ubuntu-latest
python-version: '3.13'
python-version: '3.14'
tags: []

- os: ubuntu-latest
python-version: '3.12'
tags: []

- os: ubuntu-latest
python-version: '3.11'
tags: cov

- os: ubuntu-latest
python-version: '3.10'
tags: []
tags: cov

- os: macos-latest
python-version: '3.11'
Expand Down
28 changes: 18 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
]
description = "Likelihood and Theory codes for the Simons Observatory."
readme = "README.rst"
requires-python = ">3.9,<3.14" # 3.14 is conflicting with many dependencies
requires-python = ">3.9,<3.15"
license = { text = "MIT" }

dependencies = [
Expand All @@ -27,24 +27,22 @@ Documentation = "https://soliket.readthedocs.io/en/latest/"

[project.optional-dependencies]
emulator = [
"cosmopower (>=0.2.0); python_version < '3.12' and sys_platform != 'win32'", # from tensorflow
"tensorflow-probability (>=0.20.1); python_version < '3.12' and sys_platform != 'win32'", # breaking change
"tensorflow (>=2.12); python_version < '3.12' and sys_platform != 'win32'", # from python compatibility
"cosmopower @ git+https://github.com/HTJense/cosmopower.git@main ; python_version < '3.14' and sys_platform != 'win32'", # from tensorflow
"tf-keras; python_version < '3.14' and sys_platform != 'win32'", # needed by tensorflow-probability>=0.25
]
pyccl = [
"pyccl>=3.1.2 ; sys_platform != 'win32' and python_version < '3.13'", # for stability
"pyccl @ git+https://github.com/LSSTDESC/CCL.git@master ; sys_platform != 'win32' and python_version < '3.13'",
Copy link
Collaborator

@itrharrison itrharrison Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be aware that we would no longer be able to deploy to pypi because of taking dependencies from git.

In person we discussed with @anicola that it is unlikely the pyccl pip package will continue to be maintained, but the conda one will.

I guess we could cheat the system a little by keeping these requirements out of our pyproject.toml but including them in the uv env(?). But of course then it would be very easy for a user to acquire a non-functioning installation via pip. If such a naive user exists(?)...

]
pyhalomodel = [
"pyhalomodel (>=1.0.1); python_version < '3.13'", # from python compatibility
]
mflike = [
"mflike (>=1.0.1); python_version < '3.13'", # breaking change
"fgspectra (>=1.3.0); python_version < '3.13'", # from mflike
"syslibrary (>=0.2.0); python_version < '3.13'", # from mflike
"mflike (>=1.0.1)", # breaking change
"fgspectra (>=1.3.0)", # from mflike
"syslibrary (>=0.2.0)", # from mflike
]
docs = [
"sphinx (<9); python_version < '3.12'", # tensorflow 2.13 pins typing-extensions==4.5.0
"sphinx; python_version >= '3.12'",
"sphinx",
"sphinx-rtd-theme",
]
dev = [
Expand All @@ -68,6 +66,9 @@ jupyter = [
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.version]
source = "vcs"

Expand Down Expand Up @@ -106,6 +107,13 @@ line-ending = "auto"
exclude = [".tox", "build", "cobaya_packages", "test", ".eggs"]
line-length = 90

[tool.uv]
override-dependencies = [
"tensorflow>=2.18",
"tensorflow-probability>=0.24",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can @HTJense update these dependencies directly in https://github.com/HTJense/cosmopower/blob/main/requirements.txt too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"numpy>=1.24.1",
]

[tool.coverage.run]
omit = ["tests/*", "*/tests/*"]

Expand Down
6 changes: 3 additions & 3 deletions soliket/clusters/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def _get_catalog(self) -> pd.DataFrame:

return pd.DataFrame(
{
"z": self.survey.clst_z.byteswap().newbyteorder(),
"tsz_signal": self.survey.clst_y0.byteswap().newbyteorder(),
"tsz_signal_err": self.survey.clst_y0err.byteswap().newbyteorder(),
"z": np.asarray(self.survey.clst_z, dtype=np.float64),
"tsz_signal": np.asarray(self.survey.clst_y0, dtype=np.float64),
"tsz_signal_err": np.asarray(self.survey.clst_y0err, dtype=np.float64),
}
)

Expand Down
16 changes: 12 additions & 4 deletions soliket/cosmopower/cosmopower.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ def initialize(self):
netpath = os.path.join(self.network_path, nettype["filename"])

if nettype["type"] == "NN":
network = cp.cosmopower_NN(restore=True, restore_filename=netpath)
network = cp.cosmopower_NN(
restore_filename=netpath, allow_pickle=True
)
elif nettype["type"] == "PCAplusNN":
network = cp.cosmopower_PCAplusNN(restore=True, restore_filename=netpath)
network = cp.cosmopower_PCAplusNN(
restore_filename=netpath, allow_pickle=True
)
elif self.stop_at_error: # pragma: no cover
raise ValueError(
f"Unknown network type {nettype['type']} for network {spectype}."
Expand Down Expand Up @@ -309,9 +313,13 @@ def initialize(self):
netpath = os.path.join(self.network_path, self.network_settings["filename"])

if self.network_settings["type"] == "NN":
self.network = cp.cosmopower_NN(restore=True, restore_filename=netpath)
self.network = cp.cosmopower_NN(
restore_filename=netpath, allow_pickle=True
)
elif self.network_settings["type"] == "PCAplusNN":
self.network = cp.cosmopower_PCAplusNN(restore=True, restore_filename=netpath)
self.network = cp.cosmopower_PCAplusNN(
restore_filename=netpath, allow_pickle=True
)
else:
raise LoggedError(f"Unknown network type {self.network_settings['type']}.")

Expand Down
Binary file added soliket/cosmopower/data/CP_paper/cmb_EE_NN.npz
Binary file not shown.
Binary file not shown.
Binary file added soliket/cosmopower/data/CP_paper/cmb_TT_NN.npz
Binary file not shown.
6 changes: 3 additions & 3 deletions tests/test_cosmopower.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ def test_cosmopower_loglike(
)
model_cp = get_model(info_dict)

logL_cp = float(model_cp.loglikes({})[0])
logL_cp = np.float64(model_cp.loglikes({})[0]).item()

assert np.isclose(logL_cp, ref["value"], rtol=ref["rtol"], atol=ref["atol"])


def test_cosmopower_against_camb(request, check_skip_cosmopower, install_planck_lite):
info_dict["theory"] = {"camb": {"stop_at_error": True}}
model_camb = get_model(info_dict)
logL_camb = float(model_camb.loglikes({})[0])
logL_camb = np.float64(model_camb.loglikes({})[0]).item()
camb_cls = model_camb.theory["camb"].get_Cl()

info_dict["theory"] = {
Expand All @@ -147,7 +147,7 @@ def test_cosmopower_against_camb(request, check_skip_cosmopower, install_planck_
}

model_cp = get_model(info_dict)
logL_cp = float(model_cp.loglikes({})[0])
logL_cp = np.float64(model_cp.loglikes({})[0]).item()
cp_cls = model_cp.theory["soliket.CosmoPower"].get_Cl()

nanmask = ~np.isnan(cp_cls["tt"])
Expand Down
6 changes: 6 additions & 0 deletions tests/test_crosscov.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import sys
from tempfile import gettempdir

import numpy as np
import pytest
import sacc
from sklearn.datasets import make_spd_matrix

Expand Down Expand Up @@ -47,6 +49,10 @@ def _get_theory(self):
return np.zeros(n)


@pytest.mark.skipif(
sys.platform == "win32",
reason="astropy FITS write bug with empty records on Windows (numpy 2)",
)
def test_toy():
n1, n2, n3 = [10, 20, 30]
full_cov = make_spd_matrix(n1 + n2 + n3, random_state=1234) * 1e-1
Expand Down
Loading