Skip to content

Commit

Permalink
Lmax docstring fix (#224)
Browse files Browse the repository at this point in the history
* Lmax docs fixed, test added
  • Loading branch information
damonge authored Nov 1, 2024
1 parent 2b89ae3 commit d6e6fc1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3

- name: Set current date as environment variable
run: echo "TODAY=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
Expand Down
7 changes: 5 additions & 2 deletions pymaster/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class NmtField(object):
:meth:`~pymaster.utils.get_default_params`,
and modified via :meth:`~pymaster.utils.set_n_iter_default`.
lmax (:obj:`int`): Maximum multipole up to which map power spectra
will be computed. If negative or zero, the maximum multipole given
will be computed. If ``None``, the maximum multipole given
the map resolution will be used (e.g. :math:`3N_{\\rm side}-1`
for HEALPix maps).
lmax_mask (:obj:`int`): Maximum multipole up to which the power
spectrum of the mask will be computed. If negative or zero, the
spectrum of the mask will be computed. If ``None``, the
maximum multipole given the map resolution will be used (e.g.
:math:`3N_{\\rm side}-1` for HEALPix maps).
tol_pinv (:obj:`float`): When computing the pseudo-inverse of the
Expand Down Expand Up @@ -182,6 +182,9 @@ def __init__(self, mask, maps, *, spin=None, templates=None, beam=None,
lmax = self.minfo.get_lmax()
if lmax_mask is None:
lmax_mask = self.minfo.get_lmax()
if (lmax <= 0) or (lmax_mask <= 0):
raise ValueError("`lmax` and `lmax_mask` must be positive.")

self.ainfo = ut.NmtAlmInfo(lmax)
self.ainfo_mask = ut.NmtAlmInfo(lmax_mask)

Expand Down
6 changes: 6 additions & 0 deletions pymaster/tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,9 @@ def test_field_error():
with pytest.raises(ValueError):
f = nmt.NmtField(FT.msk, [FT.mps[1], FT.mps[2]], spin=1,
purify_b=True, n_iter=0)

# lmax must be zero
with pytest.raises(ValueError):
nmt.NmtField(FT.msk, [FT.mps[0]], lmax=0)
with pytest.raises(ValueError):
nmt.NmtField(FT.msk, [FT.mps[0]], lmax_mask=0)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pymaster"
version = "2.3.2"
version = "2.3.3"
authors = [
{name="David Alonso", email="[email protected]"}
]
Expand Down
4 changes: 2 additions & 2 deletions src/nmt_covar.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void nmt_compute_gaussian_covariance_coupled(nmt_covar_workspace *cw,
flouble *covar_out)
{
if((cw->lmax<wa->bin->ell_max) || (cw->lmax<wb->bin->ell_max))
report_error(NMT_ERROR_COVAR,"Coupling coefficients only computed up to l=%d, but you require"
report_error(NMT_ERROR_COVAR,"Coupling coefficients only computed up to l=%d, but you require "
"lmax=%d. Recompute this workspace with a larger lmax\n",cw->lmax,wa->bin->ell_max);
if((cw->spin0_only) && (spin_a+spin_b+spin_c+spin_d != 0))
report_error(NMT_ERROR_COVAR,"Coupling coefficients only computed for spin=0\n");
Expand Down Expand Up @@ -191,7 +191,7 @@ void nmt_compute_gaussian_covariance(nmt_covar_workspace *cw,
flouble *covar_out)
{
if((cw->lmax<wa->bin->ell_max) || (cw->lmax<wb->bin->ell_max))
report_error(NMT_ERROR_COVAR,"Coupling coefficients only computed up to l=%d, but you require"
report_error(NMT_ERROR_COVAR,"Coupling coefficients only computed up to l=%d, but you require "
"lmax=%d. Recompute this workspace with a larger lmax\n",cw->lmax,wa->bin->ell_max);
if((cw->spin0_only) && (spin_a+spin_b+spin_c+spin_d != 0))
report_error(NMT_ERROR_COVAR,"Coupling coefficients only computed for spin=0\n");
Expand Down

0 comments on commit d6e6fc1

Please sign in to comment.