Skip to content

Commit

Permalink
Merge pull request #112 from LSSTDESC/issue110
Browse files Browse the repository at this point in the history
Fix GitHub Actions
  • Loading branch information
carlosggarcia authored Nov 13, 2024
2 parents 3a5285b + eb948e6 commit 30d0859
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 56 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,21 @@ jobs:
use-mamba: true
activate-environment: tjpcov
miniforge-version: latest
miniforge-variant: Mambaforge

- name: Cache Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT

- name: Check for cached environment
uses: actions/cache@v3
id: cache
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ${{env.CONDA}}/envs
key:
${{runner.os}}.${{runner.arch}}.mamba-py.${{matrix.python-version}}.${{hashFiles('pyproject.toml')}}.${{hashFiles('environment.yml')}}.${{steps.get-date.outputs.today}}.${{env.CACHE_NUMBER}}
# - name: Cache Date
# id: get-date
# run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
#
# - name: Check for cached environment
# uses: actions/cache@v3
# id: cache
# env:
# # Increase this value to reset cache if etc/example-environment.yml has not changed
# CACHE_NUMBER: 0
# with:
# path: ${{env.CONDA}}/envs
# key:
# ${{runner.os}}.${{runner.arch}}.mamba-py.${{matrix.python-version}}.${{hashFiles('pyproject.toml')}}.${{hashFiles('environment.yml')}}.${{steps.get-date.outputs.today}}.${{env.CACHE_NUMBER}}

- name: Install environment packages
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -97,7 +96,7 @@ jobs:
pip install -U mpi4py --no-cache-dir --no-deps
- name: Run Tests
run: coverage run --source=tjpcov -m pytest -vv tests/
run: coverage run --source=tjpcov -m pytest -vv tests && coverage lcov

- name: Run MPI Tests (OpenMPI)
run: |
Expand All @@ -122,6 +121,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true
path-to-lcov: coverage.lcov

finish:
needs: tests
Expand Down
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ dependencies:
- pytest-rerunfailures
- coveralls
- numpy
- scipy
# - scipy
- scipy<1.12 # <1.12 to avoid bug in CCL<3.1 (not in pypy) with simpson integration
- pyyaml
- pyccl>=3.0.0
- sacc>=0.12
- namaster
- namaster>2
- camb
- Jinja2
- healpy
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Physics"
]
dependencies = [
"scipy",
"scipy<1.12", # <1.12 to avoid bug in CCL<3.1 (not in pypy) with simpson integration
"numpy",
"Jinja2",
"pyyaml",
Expand All @@ -47,13 +47,13 @@ doc = [
"sphinx-book-theme",
]
nmt = [
"pymaster>=1.4.0"
"pymaster>=2"
]
mpi = [
"mpi4py"
]
full = [
"pymaster>=1.4.0",
"pymaster>=2",
"mpi4py",
"sphinx",
"sphinx-autoapi",
Expand Down
6 changes: 2 additions & 4 deletions tests/data/conf_covariance_calculator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ NaMaster:
module: pymaster
f:
n_iter: 0
lmax_sht: -1
lmax: null
lmax_mask: null
w:
lmax_mask: -1
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True
cw:
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True

cache:
Expand Down
6 changes: 2 additions & 4 deletions tests/data/conf_covariance_calculator_mpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,17 @@ NaMaster:
module: pymaster
f:
n_iter: 0
lmax_sht: -1
lmax: null
lmax_mask: null
w:
lmax_mask: -1
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True
cw:
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True

cache:
Expand Down
6 changes: 2 additions & 4 deletions tests/data/conf_covariance_gaussian_fourier_nmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,17 @@ NaMaster:
module: pymaster
f:
n_iter: 0
lmax_sht: -1
lmax: null
lmax_mask: null
w:
lmax_mask: -1
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True
cw:
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True

parameters:
Expand Down
6 changes: 2 additions & 4 deletions tests/data/conf_covariance_gaussian_fourier_nmt_txpipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@ NaMaster:
module: pymaster
f:
n_iter: 0
lmax_sht: -1
lmax: null
lmax_mask: null
w:
lmax_mask: -1
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True
cw:
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True

parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@ NaMaster:
module: pymaster
f:
n_iter: 0
lmax_sht: -1
lmax: null
lmax_mask: null
w:
lmax_mask: -1
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True
cw:
l_toeplitz: -1
l_exact: -1
dl_band: -1
n_iter: 3
recompute: True

parameters:
Expand Down
16 changes: 9 additions & 7 deletions tests/test_covariance_fourier_gaussian_nmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,18 @@ def test_get_cl_for_cov(cov_fg_nmt):

with pytest.raises(ValueError):
cov_fg_nmt.get_cl_for_cov(
cl_fid_Sh, cl["nl_cp"], m, m, w, nl_is_cp=True
cl_fid_Sh["cl"], cl["nl_cp"], m, m, w, nl_is_cp=True
)

with pytest.raises(ValueError):
# Uncoupled binned noise
cov_fg_nmt.get_cl_for_cov(cl_fid, cl["nl"], m, m, w, nl_is_cp=True)
cov_fg_nmt.get_cl_for_cov(
cl_fid["cl"], cl["nl"], m, m, w, nl_is_cp=True
)

with pytest.raises(ValueError):
cov_fg_nmt.get_cl_for_cov(
cl_fid, cl["nl_cp"], m, m, wSh, nl_is_cp=True
cl_fid["cl"], cl["nl_cp"], m, m, wSh, nl_is_cp=True
)


Expand Down Expand Up @@ -662,7 +664,7 @@ def test_get_covariance_block_cache(cov_fg_nmt, tracer_comb1, tracer_comb2):

@pytest.mark.parametrize(
"kwargs",
[{}, {"l_toeplitz": 10, "l_exact": 10, "dl_band": 10, "n_iter": 0}],
[{}, {"l_toeplitz": 10, "l_exact": 10, "dl_band": 10}],
)
def test_get_covariance_workspace(cov_fg_nmt, kwargs):
m1 = get_mask_from_dtype("galaxy_clustering")
Expand Down Expand Up @@ -715,7 +717,7 @@ def test_get_covariance_workspace(cov_fg_nmt, kwargs):
# Check only the first is written/computed created & that cw is correct

for fields, masks_names in zip(combinations, combinations_names):
spins = [fi.fl.spin for fi in fields]
spins = [fi.spin for fi in fields]
cw_code = cov_fg_nmt.get_covariance_workspace(
*fields, *masks_names, **kwargs
)
Expand Down Expand Up @@ -967,7 +969,7 @@ def get_data_types(self):

@pytest.mark.parametrize(
"kwargs",
[{}, {"l_toeplitz": 10, "l_exact": 10, "dl_band": 10, "n_iter": 0}],
[{}, {"l_toeplitz": 10, "l_exact": 10, "dl_band": 10}],
)
def test_get_workspace(cov_fg_nmt, kwargs):
# Compute NmtBins
Expand Down Expand Up @@ -1030,7 +1032,7 @@ def test_get_workspace(cov_fg_nmt, kwargs):

@pytest.mark.parametrize(
"kwargs",
[{}, {"l_toeplitz": 10, "l_exact": 10, "dl_band": 10, "n_iter": 0}],
[{}, {"l_toeplitz": 10, "l_exact": 10, "dl_band": 10}],
)
def test_get_workspace_dict(cov_fg_nmt, kwargs):
tracers = get_tracers_dict_for_cov()
Expand Down
13 changes: 6 additions & 7 deletions tjpcov/covariance_fourier_gaussian_nmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ def get_covariance_block(
mn[2],
mn[3],
mn[4],
lmax=int(ell[-1]),
**self.nmt_conf["cw"],
)

Expand Down Expand Up @@ -385,10 +384,10 @@ def get_covariance_workspace(
"""
outdir = self.io.outdir
spins = {
m1: f1.fl.spin,
m2: f2.fl.spin,
m3: f3.fl.spin,
m4: f4.fl.spin,
m1: f1.spin,
m2: f2.spin,
m3: f3.spin,
m4: f4.spin,
}

# Any other symmetry?
Expand Down Expand Up @@ -673,7 +672,7 @@ def get_workspace(self, f1, f2, m1, m2, bins, **kwargs):
)

outdir = self.io.outdir
s1, s2 = f1.fl.spin, f2.fl.spin
s1, s2 = f1.spin, f2.spin

# Currently, outdir will be always not None. If not specified, it
# will be the current directory. I leave this for now since we might
Expand Down Expand Up @@ -763,7 +762,7 @@ def get_workspaces_dict(
if key in cache:
w[i] = cache[key]
else:
s1, s2 = fields[i1].fl.spin, fields[i2].fl.spin
s1, s2 = fields[i1].spin, fields[i2].spin
# In this case you have to check for m1 x m2 and m2 x m1
k = (mask_names[i1], mask_names[i2])
sk = "".join(sorted(f"{s1}{s2}"))
Expand Down
2 changes: 1 addition & 1 deletion tjpcov/covariance_gaussian_fsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_binning_info(self, binning="linear"):
# TODO: This should be obtained from the sacc file or the input
# configuration. Check how it is done in TXPipe:
# https://github.com/LSSTDESC/TXPipe/blob/a9dfdb7809ac7ed6c162fd3930c643a67a
out = self.get_binning_info()
out = super().get_binning_info()
if out is not None:
ell = out[0]
ell_eff = out[1]
Expand Down

0 comments on commit 30d0859

Please sign in to comment.