Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the tests pull out common parts to pytest fixtures #25

Open
samaloney opened this issue Nov 16, 2017 · 0 comments
Open

Refactor the tests pull out common parts to pytest fixtures #25

samaloney opened this issue Nov 16, 2017 · 0 comments

Comments

@samaloney
Copy link
Member

samaloney commented Nov 16, 2017

A lot of the test are repetitive leaving more room for errors in the test themselves for example the test_dft_idft_map, test_dft_idft_map_pixel_size, test_dft_idft_map_center and test_dft_idft_map_shape_pixel_size could all be combined into one test.

@pytest.mark.parametrize('shape', [(3, 3), (2, 3), (3, 2), (2, 2)])
@pytest.mark.parametrize('pixel_size', [(1, 1), (1, 2), (2, 1), (2, 2)])
@pytest.mark.parametrize('center', [(0, 0), (-1, 1), (1, -1), (1, 1)])
def test_dft_idft(shape, pixel_size, center):
    data = np.arange(np.prod(shape)).reshape(shape)
    uu = generate_uv(shape[0] * apu.pix, phase_centre=0 * apu.arcsec, pixel_size=pixel_size[0] * apu.arcsec / apu.pix)
    vv = generate_uv(shape[1] * apu.pix, phase_centre=0 * apu.arcsec, pixel_size=pixel_size[1] * apu.arcsec / apu.pix)
    u, v = np.meshgrid(uu, vv, indexing='ij')
    u = u.flatten()
    v = v.flatten()

    vis = dft_map(data, u=u, v=v, pixel_size=pixel_size * apu.arcsec / apu.pix)
    img = idft_map(vis, u=u, v=v, shape=shape * apu.pix, pixel_size=pixel_size * apu.arcsec / apu.pix)
    img = np.around(img / np.prod(shape))
    assert_allclose(data, img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant