Commit ddff3959 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add more tests for weights

parent 75ef2a80
......@@ -198,9 +198,7 @@ def test_applyholo(nxdirty, nydirty, nrow, nchan, epsilon, weight):
ms = np.random.rand(nrow, nchan)-0.5 + 1j*(np.random.rand(nrow, nchan)-0.5)
vis = bl.ms2vis(ms, idx)
grid = ng.vis2grid_c(bl, conf, idx, vis)
wgt = None
if weight:
wgt = np.random.rand(*vis.shape)
wgt = np.random.rand(*vis.shape) if weight else None
y0 = ng.apply_holo(bl, conf, idx, grid, wgt)
y1 = ng.vis2grid_c(bl, conf, idx, ng.grid2vis_c(bl, conf, idx, grid, wgt),
wgt=wgt)
......@@ -214,13 +212,14 @@ def test_applyholo(nxdirty, nydirty, nrow, nchan, epsilon, weight):
@pmp("epsilon", (1e-2, 1e-7))
@pmp("du", (-2, 0, 1, 4))
@pmp("dv", (-1, 0, 1))
def test_correlations(nxdirty, nydirty, nrow, nchan, epsilon, du, dv):
# FIXME Include weights
@pmp("weight", (True, False))
def test_correlations(nxdirty, nydirty, nrow, nchan, epsilon, du, dv, weight):
np.random.seed(42)
bl, conf, idx = _init_gridder(nxdirty, nydirty, epsilon, nchan, nrow)
if conf.W() <= abs(du) or conf.W() <= dv:
return
y0 = ng.get_correlations(bl, conf, idx, du, dv)
wgt = np.random.rand(*idx.shape) if weight else None
y0 = ng.get_correlations(bl, conf, idx, du, dv, wgt)
pts = ((nxdirty, nydirty),
(nxdirty + 1, nydirty),
(nxdirty, nydirty//2),
......@@ -229,7 +228,7 @@ def test_correlations(nxdirty, nydirty, nrow, nchan, epsilon, du, dv):
for pp in pts:
grid = np.zeros((2*nxdirty, 2*nydirty))
grid[pp] = 1
y1 = ng.apply_holo(bl, conf, idx, grid)
y1 = ng.apply_holo(bl, conf, idx, grid, wgt)
ind = (pp[0]+du) % (2*nxdirty), (pp[1]+dv) % (2*nydirty)
assert_allclose(y0[pp], y1[ind].real)
assert_allclose(np.zeros_like(y1), y1.imag)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment