Skip to content

Commit 78236c3

Browse files
committed
Add failing test demonstrating error in uv/vis-index handling
This occurs when some (but not all) uv-positions are out-of-bounds.
1 parent 5c36d64 commit 78236c3

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

‎tests/test_gridder/test_exact_gridding.py‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,46 @@ def test_bounds_checking():
4444
# n_image = 8 then the co-ords in the u/x-direction are:
4545
# [-4, -3, -2, -1, 0, 1, 2, 3 ]
4646
# Support = 2 takes this over the edge (since -3 -2 = -5):
47-
uv = np.array([(-3., 0)])
48-
vis = np.ones(len(uv), dtype=np.float_)
47+
bad_uv = np.array([(-3., 0)])
48+
vis = np.ones(len(bad_uv), dtype=np.float_)
4949
kernel_func = conv_funcs.Pillbox(1.5)
5050

5151
with pytest.raises(ValueError):
5252
grid = convolve_to_grid(kernel_func,
5353
support=support,
5454
image_size=n_image,
55-
uv=uv, vis=vis)
55+
uv=bad_uv, vis=vis)
5656

5757
grid, _ = convolve_to_grid(kernel_func,
5858
support=support,
5959
image_size=n_image,
60-
uv=uv, vis=vis,
60+
uv=bad_uv, vis=vis,
6161
raise_bounds=False
6262
)
6363
assert grid.sum() == 0.
6464

65+
# Now check we're filtering indices in the correct order
66+
# The mixed
67+
good_uv = np.array([(0., 0.)])
68+
mixed_uv = np.array([(-3., 0),
69+
(0., 0.)])
70+
good_grid, _ = convolve_to_grid(kernel_func,
71+
support=support,
72+
image_size=n_image,
73+
uv=good_uv,
74+
vis=np.ones(len(good_uv), dtype=np.float_),
75+
raise_bounds=False
76+
)
77+
mixed_grid, _ = convolve_to_grid(kernel_func,
78+
support=support,
79+
image_size=n_image,
80+
uv=mixed_uv,
81+
vis=np.ones(len(mixed_uv), dtype=np.float_),
82+
raise_bounds=False
83+
)
84+
85+
assert (good_grid == mixed_grid).all()
86+
6587

6688
def test_multi_pixel_pillbox():
6789
n_image = 8

0 commit comments

Comments
 (0)