Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeRZP committed Oct 21, 2024
1 parent f019969 commit fc5ab14
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def test_positions(mapper, catalog, vmap):
"lmax": mapper.lmax,
"deconv": mapper.deconvolve,
"bias": pytest.approx(bias / nbar**2),
"var": 1.0,
"ngal": int(4.0 * npix),
"wmean": 1.0,
"ngal": 4.0 * npix,
"var": 1.0,
}
np.testing.assert_array_equal(m, 0)

Expand All @@ -227,6 +227,9 @@ def test_positions(mapper, catalog, vmap):
"lmax": mapper.lmax,
"deconv": mapper.deconvolve,
"bias": pytest.approx(bias / nbar**2),
"ngal": int(4.0 * npix),
"wmean": 1.0,
"var": 1.0,
}
np.testing.assert_array_equal(m, 1.0)

Expand All @@ -250,6 +253,9 @@ def test_positions(mapper, catalog, vmap):
"lmax": mapper.lmax,
"deconv": mapper.deconvolve,
"bias": pytest.approx(bias / nbar**2),
"ngal": int(4.0 * npix),
"wmean": 1.0,
"var": 1.0,
}

# compute number count map with visibility map
Expand All @@ -268,6 +274,9 @@ def test_positions(mapper, catalog, vmap):
"lmax": mapper.lmax,
"deconv": mapper.deconvolve,
"bias": pytest.approx(bias / nbar**2),
"ngal": int(4.0 * npix),
"wmean": 1.0,
"var": 1.0,
}

# compute overdensity maps with given (incorrect) nbar
Expand All @@ -293,6 +302,7 @@ def test_scalar_field(mapper, catalog):
v2 = ((w * v) ** 2).sum()
w = w.reshape(w.size // 4, 4).sum(axis=-1)
wbar = w.mean()
v1 = w.sum()
bias = (4 * np.pi / npix / npix) * v2

assert m.shape == (npix,)
Expand All @@ -306,9 +316,9 @@ def test_scalar_field(mapper, catalog):
"lmax": mapper.lmax,
"deconv": mapper.deconvolve,
"bias": pytest.approx(bias / wbar**2),
"ngal": 4.0 * npix,
"wmean": wbar,
"var": v2,
"ngal": int(4.0 * npix),
"wmean": pytest.approx(v1 / (4.0 * npix)),
"var": v2 / (4.0 * npix),
}
np.testing.assert_array_almost_equal(m, 0)

Expand All @@ -327,8 +337,8 @@ def test_complex_field(mapper, catalog):
v2 = ((w * re) ** 2 + (w * im) ** 2).sum()
w = w.reshape(w.size // 4, 4).sum(axis=-1)
wbar = w.mean()
v1 = w.sum()
bias = (4 * np.pi / npix / npix) * v2 / 2

assert m.shape == (2, npix)
assert m.dtype.metadata == {
"catalog": catalog.label,
Expand All @@ -340,9 +350,9 @@ def test_complex_field(mapper, catalog):
"lmax": mapper.lmax,
"deconv": mapper.deconvolve,
"bias": pytest.approx(bias / wbar**2),
"ngal": 4.0 * npix,
"wmean": wbar,
"var": v2,
"ngal": int(4.0 * npix),
"wmean": v1 / (4.0 * npix),
"var": v2 / (4.0 * npix),
}
np.testing.assert_array_almost_equal(m, 0)

Expand Down

0 comments on commit fc5ab14

Please sign in to comment.