def test_get_boundary_coords(): r"""Test get spatial corners of data positions function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) truth = {'east': 9, 'north': 9, 'south': 0, 'west': 0} assert bbox == truth bbox = get_boundary_coords(x, y, 10) truth = {'east': 19, 'north': 19, 'south': -10, 'west': -10} assert bbox == truth
def test_get_boundary_coords(): r"""Test get spatial corners of data positions function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) truth = {'east': 9, 'north': 9, 'south': 0, 'west': 0} assert bbox == truth bbox = get_boundary_coords(x, y, 10) truth = {'east': 19, 'north': 19, 'south': -10, 'west': -10} assert bbox == truth
def test_get_xy_range(): r"""Test get range of data positions function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) x_range, y_range = get_xy_range(bbox) truth_x = 9 truth_y = 9 assert truth_x == x_range assert truth_y == y_range
def test_get_xy_steps(): r"""Test get count of grids function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) x_steps, y_steps = get_xy_steps(bbox, 3) truth_x = 3 truth_y = 3 assert x_steps == truth_x assert y_steps == truth_y
def test_get_xy_range(): r"""Test get range of data positions function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) x_range, y_range = get_xy_range(bbox) truth_x = 9 truth_y = 9 assert truth_x == x_range assert truth_y == y_range
def test_get_xy_steps(): r"""Test get count of grids function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) x_steps, y_steps = get_xy_steps(bbox, 3) truth_x = 3 truth_y = 3 assert x_steps == truth_x assert y_steps == truth_y
def test_generate_grid(): r"""Test generate grid function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) gx, gy = generate_grid(3, bbox) truth_x = np.array([[0.0, 4.5, 9.0], [0.0, 4.5, 9.0], [0.0, 4.5, 9.0]]) truth_y = np.array([[0.0, 0.0, 0.0], [4.5, 4.5, 4.5], [9.0, 9.0, 9.0]]) assert_array_almost_equal(gx, truth_x) assert_array_almost_equal(gy, truth_y)
def test_generate_grid_coords(): r"""Test generate grid coordinates function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) gx, gy = generate_grid(3, bbox) truth = [[0.0, 0.0], [4.5, 0.0], [9.0, 0.0], [0.0, 4.5], [4.5, 4.5], [9.0, 4.5], [0.0, 9.0], [4.5, 9.0], [9.0, 9.0]] pts = generate_grid_coords(gx, gy) assert_array_almost_equal(truth, pts)
def test_generate_grid_coords(): r"""Test generate grid coordinates function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) gx, gy = generate_grid(3, bbox) truth = [[0.0, 0.0], [4.5, 0.0], [9.0, 0.0], [0.0, 4.5], [4.5, 4.5], [9.0, 4.5], [0.0, 9.0], [4.5, 9.0], [9.0, 9.0]] pts = generate_grid_coords(gx, gy) assert_array_almost_equal(truth, pts) assert pts.flags['C_CONTIGUOUS'] # need output to be C-contiguous
def test_generate_grid(): r"""Test generate grid function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) gx, gy = generate_grid(3, bbox) truth_x = np.array([[0.0, 4.5, 9.0], [0.0, 4.5, 9.0], [0.0, 4.5, 9.0]]) truth_y = np.array([[0.0, 0.0, 0.0], [4.5, 4.5, 4.5], [9.0, 9.0, 9.0]]) assert_array_almost_equal(gx, truth_x) assert_array_almost_equal(gy, truth_y)
def test_generate_grid_coords(): r"""Test generate grid coordinates function.""" x = list(range(10)) y = list(range(10)) bbox = get_boundary_coords(x, y) gx, gy = generate_grid(3, bbox) truth = [[0.0, 0.0], [4.5, 0.0], [9.0, 0.0], [0.0, 4.5], [4.5, 4.5], [9.0, 4.5], [0.0, 9.0], [4.5, 9.0], [9.0, 9.0]] pts = generate_grid_coords(gx, gy) assert_array_almost_equal(truth, pts)