Skip to content

Commit

Permalink
Fix compatability (#148)
Browse files Browse the repository at this point in the history
* remove depracated likelihood.theory calls

* codestyle

* sphinx compatability update

* sphinx compatability update 2204

* add build tools

* move rtd python ver

* rtd try different pyver

* rtd try different order

* conda on rtd

* update rtd mock import

* add rtd theme

* add rtd theme correctly

* add rtd theme in setup.cfg

* Testing yaml instead of yml.

* added docs conda env

* add full requirements in docs

* pin tensorflow dep

---------

Co-authored-by: Hidde Jense <JenseH@cardiff.ac.uk>
  • Loading branch information
itrharrison and HTJense authored Oct 24, 2023
1 parent d293248 commit 3075927
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 42 deletions.
20 changes: 20 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "miniconda3-4.7"

sphinx:
configuration: docs/conf.py
fail_on_warning: false

# python:
# install:
# - requirements: docs/requirements.txt
# - method: pip
# path: .

conda:
environment: docs/soliket-docs.yml

formats: all
20 changes: 0 additions & 20 deletions .readthedocs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.insert(0, "..")

# Create some mock imports
import mock
from unittest import mock
MOCK_MODULES = ["cosmopower", "tensorflow", "pyccl", "camb"]
for module in MOCK_MODULES:
sys.modules[module] = mock.Mock()
Expand Down
19 changes: 19 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
numpy
scipy
pandas
scikit-learn
pyyaml
py-bobyqa
packaging
tqdm
portalocker
dill
fuzzywuzzy
astropy
getdist
cobaya
pyccl
sacc
fgspectra>=1.1.0
syslibrary
sphinx>=4.0
sphinx_rtd_theme
19 changes: 19 additions & 0 deletions docs/soliket-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: soliket-docs
channels:
- conda-forge
- nodefaults
dependencies:
- python>=3.8,<3.11
- pip
- pytest-cov
- compilers
- make
- cmake
- swig
- gsl
- fftw
- cython
- mpi4py
- camb
- pip:
- -r requirements.txt
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pyyaml
py-bobyqa
packaging
tqdm
tensorflow<2.14
portalocker
dill
fuzzywuzzy
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ all =
cosmopower
docs =
sphinx
sphinx_rtd_theme

[flake8]
select = E713,E704,E703,E714,E741,E10,E11,E20,E22,E23,E25,E27,E301,E302,E304,E9,
Expand Down
2 changes: 1 addition & 1 deletion soliket/ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
* ``fsigma8``
* ``sigma8_z``
Then, to obtain the results, evaluate the contents of ``self.theory.get_CCL()`` in
Then, to obtain the results, evaluate the contents of ``self.provider.get_CCL()`` in
the likelihood.
"""

Expand Down
32 changes: 16 additions & 16 deletions soliket/clusters/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,31 @@ def _get_catalog(self):
return df

def _get_om(self):
return (self.theory.get_param("omch2") + self.theory.get_param("ombh2")) / (
(self.theory.get_param("H0") / 100.0) ** 2
return (self.provider.get_param("omch2") + self.provider.get_param("ombh2")) / (
(self.provider.get_param("H0") / 100.0) ** 2
)

def _get_ob(self):
return (self.theory.get_param("ombh2")) / (
(self.theory.get_param("H0") / 100.0) ** 2
return (self.provider.get_param("ombh2")) / (
(self.provider.get_param("H0") / 100.0) ** 2
)

def _get_Ez(self):
return self.theory.get_Hubble(self.zarr) / self.theory.get_param("H0")
return self.provider.get_Hubble(self.zarr) / self.provider.get_param("H0")

def _get_Ez_interpolator(self):
return interp1d(self.zarr, self._get_Ez())

def _get_DAz(self):
return self.theory.get_angular_diameter_distance(self.zarr)
return self.provider.get_angular_diameter_distance(self.zarr)

def _get_DAz_interpolator(self):
return interp1d(self.zarr, self._get_DAz())

def _get_HMF(self):
h = self.theory.get_param("H0") / 100.0
h = self.provider.get_param("H0") / 100.0

Pk_interpolator = self.theory.get_Pk_interpolator(
Pk_interpolator = self.provider.get_Pk_interpolator(
("delta_nonu", "delta_nonu"), nonlinear=False
).P
pks = Pk_interpolator(self.zarr, self.k)
Expand All @@ -137,7 +137,7 @@ def _get_HMF(self):

Ez = (
self._get_Ez()
) # self.theory.get_Hubble(self.zarr) / self.theory.get_param("H0")
) # self.provider.get_Hubble(self.zarr) / self.provider.get_param("H0")
om = self._get_om()

hmf = mf.HMF(om, Ez, pk=pks * h**3, kh=self.k / h, zarr=self.zarr)
Expand All @@ -153,7 +153,7 @@ def _get_param_vals(self, **kwargs):
scat = 0.2
massbias = 1.0

H0 = self.theory.get_param("H0")
H0 = self.provider.get_param("H0")
ob = self._get_ob()
om = self._get_om()
param_vals = {
Expand All @@ -179,7 +179,7 @@ def _get_rate_fn(self, **kwargs):

dn_dzdm_interp = HMF.inter_dndmLogm(delta=500)

h = self.theory.get_param("H0") / 100.0
h = self.provider.get_param("H0") / 100.0

def Prob_per_cluster(z, tsz_signal, tsz_signal_err):
c_y = tsz_signal
Expand All @@ -199,15 +199,15 @@ def Prob_per_cluster(z, tsz_signal, tsz_signal_err):
# Implement a function that returns a rate function (function of (tsz_signal, z))

def _get_dVdz(self):
DA_z = self.theory.get_angular_diameter_distance(self.zarr)
DA_z = self.provider.get_angular_diameter_distance(self.zarr)

dV_dz = (
DA_z**2
* (1.0 + self.zarr) ** 2
/ (self.theory.get_Hubble(self.zarr) / C_KM_S)
/ (self.provider.get_Hubble(self.zarr) / C_KM_S)
)

# dV_dz *= (self.theory.get_param("H0") / 100.0) ** 3.0 # was h0
# dV_dz *= (self.provider.get_param("H0") / 100.0) ** 3.0 # was h0
return dV_dz

def _get_n_expected(self, **kwargs):
Expand All @@ -223,7 +223,7 @@ def _get_n_expected(self, **kwargs):

z_arr = self.zarr

h = self.theory.get_param("H0") / 100.0
h = self.provider.get_param("H0") / 100.0

Ntot = 0
dVdz = self._get_dVdz()
Expand Down Expand Up @@ -253,7 +253,7 @@ def _test_n_tot(self, **kwargs):

z_arr = self.zarr

h = self.theory.get_param("H0") / 100.0
h = self.provider.get_param("H0") / 100.0

Ntot = 0
dVdz = self._get_dVdz()
Expand Down
2 changes: 1 addition & 1 deletion soliket/mflike/mflike.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _get_theory(self, **params_values):
return self._get_power_spectra(cmbfg_dict)

def logp(self, **params_values):
cmbfg_dict = self.theory.get_cmbfg_dict()
cmbfg_dict = self.provider.get_cmbfg_dict()
return self.loglike(cmbfg_dict)

def loglike(self, cmbfg_dict):
Expand Down
2 changes: 1 addition & 1 deletion soliket/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_requirements(self):
return {"Cl": {self.kind: self.lmax}}

def _get_Cl(self):
return self.theory.get_Cl(ell_factor=True)
return self.provider.get_Cl(ell_factor=True)

def _get_theory(self, **params_values):
cl_theory = self._get_Cl()
Expand Down
2 changes: 1 addition & 1 deletion soliket/tests/test_ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CheckLike(Likelihood):
a CCL object.
"""
def logp(self, **params_values):
ccl = self.theory.get_CCL() # noqa F841
ccl = self.provider.get_CCL() # noqa F841
return -1.0

def get_requirements(self):
Expand Down
3 changes: 2 additions & 1 deletion soliket/tests/test_xcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def test_xcorr(theory):

setup_chi_out = xcorr_lhood._setup_chi()

Pk_interpolator = xcorr_lhood.theory.get_Pk_interpolator(("delta_nonu", "delta_nonu"),
Pk_interpolator = xcorr_lhood.provider.get_Pk_interpolator(("delta_nonu",
"delta_nonu"),
extrap_kmax=1.e8,
nonlinear=False).P

Expand Down

0 comments on commit 3075927

Please sign in to comment.