예제 #1
0
def test_half():
    result = cuspatial.window_points(
        -2,
        -2,
        2,
        2,
        cudf.Series([-1.0, 1.0, 3.0, -3.0]),
        cudf.Series([1.0, -1.0, 3.0, -3.0]),
    )
    print(result)
    assert_eq(result, cudf.DataFrame({"x": [-1.0, 1.0], "y": [1.0, -1.0]}))
예제 #2
0
"""
GPU-based spatial window query demo using 1.3 million points read from file
and (x1,x2,y1,y2)=[-180,180,-90,90] as the query window num should be the same
as x.data.size, both are 1338671
"""

import cuspatial

data_dir = "./data/"
data = cuspatial.read_points_lonlat(data_dir + "locust.location")

points_inside = cuspatial.window_points(-180, -90, 180, 90, data["lon"],
                                        data["lat"])
print(points_inside.shape[0])
assert points_inside.shape[0] == data.shape[0]
예제 #3
0
def test_oob():
    result = cuspatial.window_points(-1, -1, 1, 1, cudf.Series([-2, 2]),
                                     cudf.Series([2, -2]))
    assert_eq(result, cudf.DataFrame({"x": [], "y": []}))
예제 #4
0
def test_pair():
    result = cuspatial.window_points(-1.1, -1.1, 1.1, 1.1, cudf.Series([0, 1]),
                                     cudf.Series([1, 0]))
    assert_eq(result, cudf.DataFrame({"x": [0.0, 1], "y": [1, 0.0]}))
예제 #5
0
def test_corners(coords):
    x, y = coords
    result = cuspatial.window_points(-1.1, -1.1, 1.1, 1.1, cudf.Series([x]),
                                     cudf.Series([y]))
    assert_eq(result, cudf.DataFrame({"x": [x], "y": [y]}))
예제 #6
0
def test_centered():
    result = cuspatial.window_points(-1, -1, 1, 1, cudf.Series([0.0]),
                                     cudf.Series([0.0]))
    assert_eq(result, cudf.DataFrame({"x": [0.0], "y": [0.0]}))
예제 #7
0
def test_ones():
    with pytest.raises(RuntimeError):
        result = cuspatial.window_points(  # noqa: F841
            0, 0, 0, 0, cudf.Series([0.0]), cudf.Series([0.0]))