Skip to content

Commit

Permalink
Address warnings in tox tests (#124)
Browse files Browse the repository at this point in the history
* renamed TestLike to CheckLike in test_ccl.py

* replaced distutils.version.Looseversion with packaging.version.Version

* replaced deprecated interp2d with RegularGridInterpolator in clusters

* flake8 compliant

* removed python3.7 from env list in tox.ini

* removed py3.7 from conda reqs

* upgraded latest version to py3.8

* correct data types in shearkappa test file

* edits to setup.cfg for pyversion bump and fgspectra from pip

* mflike actually still required before #104 merged

---------

Co-authored-by: Martina Gerbino <bradamante@martina.local>
Co-authored-by: Ian Harrison <itrharrison@gmail.com>
  • Loading branch information
3 people authored Mar 8, 2023
1 parent c9945eb commit bbeabd2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 168 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- name: oldest supported versions
os: ubuntu-latest
python-version: '3.7'
toxenv: py37-test-oldest
python-version: '3.8'
toxenv: py38-test-oldest

- name: macOS 11
os: macos-11
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edit_on_github = True
[options]
zip_safe = False
packages = find:
python_requires = >=3.7
python_requires = >=3.8
setup_requires = setuptools_scm
install_requires =
numpy
Expand All @@ -23,7 +23,7 @@ install_requires =
cobaya
pyccl
sacc
fgspectra @ git+https://github.com/simonsobs/fgspectra@act_sz_x_cib#egg=fgspectra
fgspectra
mflike @ git+https://github.com/simonsobs/lat_mflike@master

[options.package_data]
Expand Down
2 changes: 1 addition & 1 deletion soliket-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- nodefaults
dependencies:
- python>=3.7,<3.11
- python>=3.8,<3.11
- pip
- pytest-cov
- compilers
Expand Down
2 changes: 1 addition & 1 deletion soliket/clusters/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def Prob_per_cluster(z, tsz_signal, tsz_signal_err):
HMF.M, c_z, c_y * 1e-4, c_yerr * 1e-4, param_vals, Ez_fn, DA_fn
)

dn_dzdm = 10 ** np.squeeze(dn_dzdm_interp(c_z, np.log10(HMF.M))) * h**4.0
dn_dzdm = 10 ** np.squeeze(dn_dzdm_interp((np.log10(HMF.M), c_z))) * h**4.0

ans = np.trapz(dn_dzdm * Pfunc_ind, dx=np.diff(HMF.M, axis=0), axis=0)
return ans
Expand Down
5 changes: 3 additions & 2 deletions soliket/clusters/massfunc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from scipy.interpolate import interp2d
from scipy.interpolate import RegularGridInterpolator
from .tinker import dn_dlogM
from ..constants import MSUN_CGS, G_CGS, MPC2CM

Expand Down Expand Up @@ -70,5 +70,6 @@ def inter_dndmLogm(self, delta, M=None):
if M is None:
M = self.M
dndM = self.dn_dM(M, delta)
ans = interp2d(self.zarr, np.log10(M), np.log10(dndM), kind='cubic', fill_value=0)
ans = RegularGridInterpolator((np.log10(M), self.zarr),
np.log10(dndM), method='cubic', fill_value=0)
return ans
169 changes: 14 additions & 155 deletions soliket/tests/data/des_s-act_kappa.toy-sim.sacc.fits

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions soliket/tests/test_ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from cobaya.likelihood import Likelihood


class TestLike(Likelihood):
class CheckLike(Likelihood):
"""
This is a mock likelihood that simply forces soliket.CCL to calculate
a CCL object.
Expand All @@ -32,7 +32,7 @@ def get_requirements(self):
info_dict = {
"params": fiducial_params,
"likelihood": {
"testLike": {"external": TestLike}
"checkLike": {"external": CheckLike}
},
"theory": {
"camb": {
Expand Down
4 changes: 2 additions & 2 deletions soliket/tests/test_mflike.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import tempfile
import unittest
import pytest
from distutils.version import LooseVersion
from packaging.version import Version

import camb
import mflike # noqa
Expand Down Expand Up @@ -58,7 +58,7 @@
}


if LooseVersion(camb.__version__) < LooseVersion('1.3'):
if Version(camb.__version__) < Version('1.3'):
chi2s = {"tt": 1384.5669,
"te": 1400.2760,
"ee": 1428.7597,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires =
setuptools >= 30.3.0
pip >= 19.3.1
envlist =
py{37,38,39,310}-test{,-all}{,-latest,-oldest}{,-cov}
py{38,39,310}-test{,-all}{,-latest,-oldest}{,-cov}
codestyle

[testenv]
Expand Down

0 comments on commit bbeabd2

Please sign in to comment.