From 26e779bbee4fe70b527f9aee80795622adddb46b Mon Sep 17 00:00:00 2001 From: Matthew Kwiecien Date: Fri, 5 May 2023 10:56:54 -0700 Subject: [PATCH] Updating TJPCov to require python >= 3.8 (#90) * Updating module to require python 3.8 or above. * Using pytest.approx with a relative error to fix build errors. * Sacc tracers map and misc are now case sensitive and require first letter capitalized. Updating tests. * Also requiring newest version of sacc --- .github/workflows/test.yaml | 4 ++-- .readthedocs.yaml | 2 +- environment.yml | 2 +- pyproject.toml | 4 ++-- tests/test_covariance_clusters.py | 2 +- tests/test_covariance_fourier_base.py | 6 +++--- tests/test_covariance_fourier_gaussian_nmt.py | 4 ++-- tests/test_wigner_transform.py | 7 ++++--- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6e91a009..779b2c39 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,10 +15,10 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - - name: Set up Python 3.7 + - name: Set up Python 3.8 uses: actions/setup-python@v2 with: - python-version: '3.7' + python-version: '3.8' # TODO: Fix cache # Commented out because cache makes the actions to fail diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bb384379..50e2f6f3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 build: os: ubuntu-20.04 tools: - python: "3.7" + python: "3.8" # Build documentation in the docs/ directory with Sphinx sphinx: diff --git a/environment.yml b/environment.yml index 83694b83..6f5e82c8 100755 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge - defaults dependencies: - - python=3.7 + - python>=3.8 - mpi4py - pip - numpy diff --git a/pyproject.toml b/pyproject.toml index 0ee83bf1..53deefa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ authors = [ ] description = "Covariances for LSST DESC" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.8" classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3", @@ -30,7 +30,7 @@ dependencies = [ "pytest", "pytest-rerunfailures", "pyccl>=2.5.0", - "sacc>=0.7", + "sacc>=0.8", "camb", "healpy", "h5py" diff --git a/tests/test_covariance_clusters.py b/tests/test_covariance_clusters.py index c4eb955a..eec3fdad 100644 --- a/tests/test_covariance_clusters.py +++ b/tests/test_covariance_clusters.py @@ -49,7 +49,7 @@ def mock_sacc(): # hacks the class to work without building # an entire sacc file for this test. s.add_tracer( - "misc", + "Misc", "clusters_0_0", metadata={ "Mproxy_name": "richness", diff --git a/tests/test_covariance_fourier_base.py b/tests/test_covariance_fourier_base.py index 4271bc41..7aa9d7ae 100644 --- a/tests/test_covariance_fourier_base.py +++ b/tests/test_covariance_fourier_base.py @@ -20,7 +20,7 @@ def mock_sacc(): def setup_module(): - os.makedirs(OUTDIR) + os.makedirs(OUTDIR, exist_ok=True) def teardown_module(): @@ -41,7 +41,7 @@ def mock_cov_fourier(): def get_dummy_sacc(): s = sacc.Sacc() s.add_tracer( - "map", "PLAcv", quantity="cmb_convergence", spin=0, ell=None, beam=None + "Map", "PLAcv", quantity="cmb_convergence", spin=0, ell=None, beam=None ) s.add_tracer( "NZ", "DESgc__0", quantity="galaxy_density", spin=0, nz=None, z=None @@ -49,7 +49,7 @@ def get_dummy_sacc(): s.add_tracer( "NZ", "DESwl__0", quantity="galaxy_shear", spin=2, nz=None, z=None ) - s.add_tracer("misc", "ForError", quantity="generic") + s.add_tracer("Misc", "ForError", quantity="generic") return s diff --git a/tests/test_covariance_fourier_gaussian_nmt.py b/tests/test_covariance_fourier_gaussian_nmt.py index 0392b502..093f9a1b 100644 --- a/tests/test_covariance_fourier_gaussian_nmt.py +++ b/tests/test_covariance_fourier_gaussian_nmt.py @@ -130,7 +130,7 @@ def get_data_cl(tr1, tr2, remove_be=False): def get_dummy_sacc(): s = sacc.Sacc() s.add_tracer( - "map", "PLAcv", quantity="cmb_convergence", spin=0, ell=None, beam=None + "Map", "PLAcv", quantity="cmb_convergence", spin=0, ell=None, beam=None ) s.add_tracer( "NZ", "DESgc__0", quantity="galaxy_density", spin=0, nz=None, z=None @@ -138,7 +138,7 @@ def get_dummy_sacc(): s.add_tracer( "NZ", "DESwl__0", quantity="galaxy_shear", spin=2, nz=None, z=None ) - s.add_tracer("misc", "ForError", quantity="generic") + s.add_tracer("Misc", "ForError", quantity="generic") return s diff --git a/tests/test_wigner_transform.py b/tests/test_wigner_transform.py index ea3ddb64..4609c10d 100644 --- a/tests/test_wigner_transform.py +++ b/tests/test_wigner_transform.py @@ -149,16 +149,17 @@ def test_wigner_d_parallel(s1, s2): ell = kwargs["ell"] wd = wigner_transform.wigner_d(s1, s2, theta, ell) wd2 = wigner_transform.wigner_d_parallel(s1, s2, theta, ell) - assert np.all(wd == wd2) + assert wd.flatten() == pytest.approx(wd2.flatten(), rel=1e-10) wd2 = wigner_transform.wigner_d_parallel(s1, s2, theta, ell, ncpu=4) - assert np.all(wd == wd2) + assert wd.flatten() == pytest.approx(wd2.flatten(), rel=1e-10) wd = wigner_transform.wigner_d(s1, s2, theta, ell, l_use_bessel=None) wd2 = wigner_transform.wigner_d_parallel( s1, s2, theta, ell, l_use_bessel=None ) - assert np.all(wd == wd2) + + assert wd.flatten() == pytest.approx(wd2.flatten(), rel=1e-10) def test_bin_cov():