Skip to content

Commit

Permalink
update code for namaster v2
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosggarcia committed Oct 31, 2024
1 parent 3a5285b commit a6e5814
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 39 deletions.
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
14 changes: 7 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,16 @@ 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 +662,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 +715,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 +967,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 +1030,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
15 changes: 8 additions & 7 deletions tjpcov/covariance_fourier_gaussian_nmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def get_covariance_block(
mn[2],
mn[3],
mn[4],
lmax=int(ell[-1]),
# lmax=int(ell[-1]), # Not available in NaMaster v2
**self.nmt_conf["cw"],
)

Expand Down Expand Up @@ -385,10 +385,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 @@ -481,6 +481,7 @@ def get_fields_dict(self, tracer_names, cache=None, masks=None, **kwargs):
# We add the spin to make sure we distinguish fields of
# different types even though they share the same mask
k = mask_names[i] + str(spins[i])
print(nmt_conf)
if k not in f_by_mask_name:
f_by_mask_name[k] = nmt.NmtField(
masks[i], None, spin=spins[i], **nmt_conf
Expand Down Expand Up @@ -673,7 +674,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 +764,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

0 comments on commit a6e5814

Please sign in to comment.